Skip to content

Commit

Permalink
Update dependencies (fixed) (#131)
Browse files Browse the repository at this point in the history
* Update dependencies

* Updated dependencies

* chore(workflows): update node matrix to 18, 20

---------

Co-authored-by: James Sumners <[email protected]>
  • Loading branch information
10xLaCroixDrinker and jsumners authored Oct 15, 2024
1 parent 6a7268e commit e04fa49
Show file tree
Hide file tree
Showing 20 changed files with 309 additions and 275 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-latest]
node-version: [10, 12, 14, 15, 16]
node-version: [18, 20]
debug: [2, 3, 4]
steps:
- name: Checkout
Expand Down
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
node_modules/
package-lock.json
coverage/
.nyc_output/
.tap/
tmp/
npm-debug.log*
.DS_Store
.idea
.idea
.vscode
6 changes: 5 additions & 1 deletion .npmignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
example/
coverage/
.nyc_output/
.nyc_output/
.tap/
scripts/
.github/
test/
8 changes: 8 additions & 0 deletions .nycrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
use-spawn-wrap: true
include: [index.js, debug.js]
reporter: [text, lcov, html]
check-coverage: true
statements: 100
branches: 97
functions: 100
lines: 100
7 changes: 3 additions & 4 deletions .taprc
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
esm: false
ts: false
jsx: false
coverage: true
timeout: 480
reporter: terse
include: [test/*.js]
disable-coverage: true
34 changes: 17 additions & 17 deletions benchmarks/basic.bench.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
'use strict'
var wrap = require('module').wrap
var bench = require('fastbench')
var pino = require('pino')
var fs = require('fs')
var dest = process.platform === 'win32' ? fs.createWriteStream('\\\\.\\NUL') : fs.createWriteStream('/dev/null')
var plog = pino(dest)
const wrap = require('module').wrap
const bench = require('fastbench')
let pino = require('pino')
const fs = require('fs')
const dest = process.platform === 'win32' ? fs.createWriteStream('\\\\.\\NUL') : fs.createWriteStream('/dev/null')
const plog = pino(dest)

process.env.DEBUG = 'dlog'
var dlog = require('debug')('dlog')
const dlog = require('debug')('dlog')
dlog.log = function (s) { dest.write(s) }

delete require.cache[require.resolve('debug')]
Expand All @@ -16,8 +16,8 @@ delete require.cache[require.resolve('debug/src/node')]

delete require.cache[require.resolve('pino')]
pino = require('pino')
require('../')(pino({level: 'debug'}, dest))
var pdlog = require('debug')('dlog')
require('../')(pino({ level: 'debug' }, dest))
const pdlog = require('debug')('dlog')

delete require.cache[require.resolve('debug')]
delete require.cache[require.resolve('debug/src/debug.js')]
Expand All @@ -28,31 +28,31 @@ require('module').wrap = wrap

delete require.cache[require.resolve('pino')]
pino = require('pino')
require('../')(pino({extreme: true, level: 'debug'}, dest))
var pedlog = require('debug')('dlog')
require('../')(pino({ extreme: true, level: 'debug' }, dest))
const pedlog = require('debug')('dlog')

var max = 10
var run = bench([
const max = 10
const run = bench([
function benchPino (cb) {
for (var i = 0; i < max; i++) {
for (let i = 0; i < max; i++) {
plog.info('hello world')
}
setImmediate(cb)
},
function benchDebug (cb) {
for (var i = 0; i < max; i++) {
for (let i = 0; i < max; i++) {
dlog('hello world')
}
setImmediate(cb)
},
function benchPinoDebug (cb) {
for (var i = 0; i < max; i++) {
for (let i = 0; i < max; i++) {
pdlog('hello world')
}
setImmediate(cb)
},
function benchPinoExtremeDebug (cb) {
for (var i = 0; i < max; i++) {
for (let i = 0; i < max; i++) {
pedlog('hello world')
}
setImmediate(cb)
Expand Down
36 changes: 18 additions & 18 deletions benchmarks/deep-object.bench.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
'use strict'
var wrap = require('module').wrap
var bench = require('fastbench')
var pino = require('pino')
var fs = require('fs')
var dest = process.platform === 'win32' ? fs.createWriteStream('\\\\.\\NUL') : fs.createWriteStream('/dev/null')
var plog = pino(dest)
const wrap = require('module').wrap
const bench = require('fastbench')
let pino = require('pino')
const fs = require('fs')
const dest = process.platform === 'win32' ? fs.createWriteStream('\\\\.\\NUL') : fs.createWriteStream('/dev/null')
const plog = pino(dest)

process.env.DEBUG = 'dlog'
var dlog = require('debug')('dlog')
const dlog = require('debug')('dlog')
dlog.log = function (s) { dest.write(s) }

delete require.cache[require.resolve('debug')]
Expand All @@ -16,8 +16,8 @@ delete require.cache[require.resolve('debug/src/node')]

delete require.cache[require.resolve('pino')]
pino = require('pino')
require('../')(pino({level: 'debug'}, dest))
var pdlog = require('debug')('dlog')
require('../')(pino({ level: 'debug' }, dest))
const pdlog = require('debug')('dlog')

delete require.cache[require.resolve('debug')]
delete require.cache[require.resolve('debug/src/debug.js')]
Expand All @@ -28,37 +28,37 @@ require('module').wrap = wrap

delete require.cache[require.resolve('pino')]
pino = require('pino')
require('../')(pino({extreme: true, level: 'debug'}, dest))
var pedlog = require('debug')('dlog')
require('../')(pino({ extreme: true, level: 'debug' }, dest))
const pedlog = require('debug')('dlog')

var deep = require('../package.json')
const deep = require('../package.json')
deep.deep = Object.assign({}, JSON.parse(JSON.stringify(deep)))
deep.deep.deep = Object.assign({}, JSON.parse(JSON.stringify(deep)))
deep.deep.deep.deep = Object.assign({}, JSON.parse(JSON.stringify(deep)))

var max = 10
const max = 10

var run = bench([
const run = bench([
function benchPinoDeepObj (cb) {
for (var i = 0; i < max; i++) {
for (let i = 0; i < max; i++) {
plog.info(deep)
}
setImmediate(cb)
},
function benchDebugDeepObj (cb) {
for (var i = 0; i < max; i++) {
for (let i = 0; i < max; i++) {
dlog(deep)
}
setImmediate(cb)
},
function benchPinoDebugDeepObj (cb) {
for (var i = 0; i < max; i++) {
for (let i = 0; i < max; i++) {
pdlog(deep)
}
setImmediate(cb)
},
function benchPinoExtremeDebugDeepObj (cb) {
for (var i = 0; i < max; i++) {
for (let i = 0; i < max; i++) {
pedlog(deep)
}
setImmediate(cb)
Expand Down
42 changes: 21 additions & 21 deletions benchmarks/object.bench.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
'use strict'
var wrap = require('module').wrap
var bench = require('fastbench')
var pino = require('pino')
var fs = require('fs')
var dest = process.platform === 'win32' ? fs.createWriteStream('\\\\.\\NUL') : fs.createWriteStream('/dev/null')
var plog = pino(dest)
const wrap = require('module').wrap
const bench = require('fastbench')
let pino = require('pino')
const fs = require('fs')
const dest = process.platform === 'win32' ? fs.createWriteStream('\\\\.\\NUL') : fs.createWriteStream('/dev/null')
const plog = pino(dest)

process.env.DEBUG = 'dlog'
var dlog = require('debug')('dlog')
const dlog = require('debug')('dlog')
dlog.log = function (s) { dest.write(s) }

delete require.cache[require.resolve('debug')]
Expand All @@ -16,8 +16,8 @@ delete require.cache[require.resolve('debug/src/node')]

delete require.cache[require.resolve('pino')]
pino = require('pino')
require('../')(pino({level: 'debug'}, dest))
var pdlog = require('debug')('dlog')
require('../')(pino({ level: 'debug' }, dest))
const pdlog = require('debug')('dlog')

delete require.cache[require.resolve('debug')]
delete require.cache[require.resolve('debug/src/debug.js')]
Expand All @@ -26,33 +26,33 @@ delete require.cache[require.resolve('../')]
delete require.cache[require.resolve('../debug')]
require('module').wrap = wrap

require('../')(pino({extreme: true, level: 'debug'}, dest))
var pedlog = require('debug')('dlog')
require('../')(pino({ extreme: true, level: 'debug' }, dest))
const pedlog = require('debug')('dlog')

var max = 10
const max = 10

var run = bench([
const run = bench([
function benchPinoObj (cb) {
for (var i = 0; i < max; i++) {
plog.info({hello: 'world'})
for (let i = 0; i < max; i++) {
plog.info({ hello: 'world' })
}
setImmediate(cb)
},
function benchDebugObj (cb) {
for (var i = 0; i < max; i++) {
dlog({hello: 'world'})
for (let i = 0; i < max; i++) {
dlog({ hello: 'world' })
}
setImmediate(cb)
},
function benchPinoDebugObj (cb) {
for (var i = 0; i < max; i++) {
pdlog({hello: 'world'})
for (let i = 0; i < max; i++) {
pdlog({ hello: 'world' })
}
setImmediate(cb)
},
function benchPinoExtremeDebugDeepObj (cb) {
for (var i = 0; i < max; i++) {
pedlog({hello: 'world'})
for (let i = 0; i < max; i++) {
pedlog({ hello: 'world' })
}
setImmediate(cb)
}
Expand Down
60 changes: 30 additions & 30 deletions benchmarks/runbench.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
'use strict'

var fs = require('fs')
var path = require('path')
var spawn = require('child_process').spawn
var pump = require('pump')
var split = require('split2')
var through = require('through2')
var steed = require('steed')
const fs = require('fs')
const path = require('path')
const spawn = require('child_process').spawn
const pump = require('pump')
const split = require('split2')
const through = require('through2')
const steed = require('steed')

function usage () {
return fs.createReadStream(path.join(__dirname, 'usage.txt'))
Expand All @@ -17,22 +17,22 @@ if (!process.argv[2]) {
process.exit()
}

var selectedBenchmark = process.argv[2].toLowerCase()
var benchmarkDir = path.resolve(__dirname)
var benchmarks = {
let selectedBenchmark = process.argv[2].toLowerCase()
const benchmarkDir = path.resolve(__dirname)
const benchmarks = {
basic: 'basic.bench.js',
object: 'object.bench.js',
deepobject: 'deep-object.bench.js'
}

function runBenchmark (name, done) {
var benchmarkResults = {}
const benchmarkResults = {}
benchmarkResults[name] = {}

var processor = through(function (line, enc, cb) {
var parts = ('' + line).split(': ')
var parts2 = parts[0].split('*')
var logger = parts2[0].replace('bench', '')
const processor = through(function (line, enc, cb) {
const parts = ('' + line).split(': ')
const parts2 = parts[0].split('*')
const logger = parts2[0].replace('bench', '')

if (!benchmarkResults[name][logger]) benchmarkResults[name][logger] = []

Expand All @@ -45,7 +45,7 @@ function runBenchmark (name, done) {
})

console.log('Running ' + name.toUpperCase() + ' benchmark\n')
var benchmark = spawn(
const benchmark = spawn(
process.argv[0],
[path.join(benchmarkDir, benchmarks[name])]
)
Expand All @@ -60,23 +60,23 @@ function runBenchmark (name, done) {
}

function sum (ar) {
var result = 0
for (var i = 0; i < ar.length; i += 1) {
let result = 0
for (let i = 0; i < ar.length; i += 1) {
result += Number.parseFloat(ar[i].time)
}
return result
}

function displayResults (results) {
console.log('==========')
var benchNames = Object.keys(results)
for (var i = 0; i < benchNames.length; i += 1) {
const benchNames = Object.keys(results)
for (let i = 0; i < benchNames.length; i += 1) {
console.log(benchNames[i] + ' averages')
var benchmark = results[benchNames[i]]
var loggers = Object.keys(benchmark)
for (var j = 0; j < loggers.length; j += 1) {
var logger = benchmark[loggers[j]]
var average = Math.round(sum(logger) / logger.length)
const benchmark = results[benchNames[i]]
const loggers = Object.keys(benchmark)
for (let j = 0; j < loggers.length; j += 1) {
const logger = benchmark[loggers[j]]
const average = Math.round(sum(logger) / logger.length)
console.log(loggers[j] + ' average: ' + average)
}
}
Expand All @@ -87,14 +87,14 @@ function toBench (done) {
runBenchmark(this.name, done)
}

var benchQueue = []
const benchQueue = []
if (selectedBenchmark !== 'all') {
benchQueue.push(toBench.bind({name: selectedBenchmark}))
benchQueue.push(toBench.bind({ name: selectedBenchmark }))
} else {
var keys = Object.keys(benchmarks)
for (var i = 0; i < keys.length; i += 1) {
const keys = Object.keys(benchmarks)
for (let i = 0; i < keys.length; i += 1) {
selectedBenchmark = keys[i]
benchQueue.push(toBench.bind({name: selectedBenchmark}))
benchQueue.push(toBench.bind({ name: selectedBenchmark }))
}
}
steed.series(benchQueue, function (err, results) {
Expand Down
Loading

0 comments on commit e04fa49

Please sign in to comment.