From a80d977bebf75903b075152767755cc1418e1ac3 Mon Sep 17 00:00:00 2001 From: Andrey Osiyuk Date: Sun, 28 Apr 2024 01:05:42 +0400 Subject: [PATCH] Fix Object.create(null) (#507) --- package.json | 2 +- test/basic.test.js | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index 8d22d8bd..628a11e1 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/test/basic.test.js b/test/basic.test.js index 0201e69a..1ee96c35 100644 --- a/test/basic.test.js +++ b/test/basic.test.js @@ -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' @@ -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) => {