Skip to content

Commit

Permalink
Fix Object.create(null) (#507)
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisands authored Apr 27, 2024
1 parent 6f0ecf0 commit a80d977
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
"dependencies": {
"colorette": "^2.0.7",
"dateformat": "^4.6.3",
"fast-copy": "^3.0.0",
"fast-copy": "^3.0.2",
"fast-safe-stringify": "^2.1.1",
"help-me": "^5.0.0",
"joycon": "^3.1.1",
Expand Down
19 changes: 19 additions & 0 deletions test/basic.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ function prettyFactory (opts) {
return _prettyFactory(opts)
}

const Empty = function () {}
Empty.prototype = Object.create(null)

// All dates are computed from 'Fri, 30 Mar 2018 17:35:28 GMT'
const epoch = 1522431328992
const formattedEpoch = '17:35:28.992'
Expand Down Expand Up @@ -925,6 +928,22 @@ test('basic prettifier tests', (t) => {
t.equal(arst, `[${formattedEpoch}] INFO: hello world\n`)
})

t.test('inlude a single key with null object', (t) => {
t.plan(1)
const pretty = prettyFactory({ include: 'level' })
const obj = new Empty()
obj.nested = 'property'
const arst = pretty({
msg: 'hello world',
pid: `${pid}`,
hostname,
time: epoch,
obj,
level: 30
})
t.equal(arst, 'INFO: hello world\n')
})

t.test('prettifies trace caller', (t) => {
t.plan(1)
const traceCaller = (instance) => {
Expand Down

0 comments on commit a80d977

Please sign in to comment.