summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorRuben Bridgewater <ruben@bridgewater.de>2019-11-21 15:12:58 +0100
committerRuben Bridgewater <ruben@bridgewater.de>2019-12-07 00:31:06 +0100
commit2a0ec9c6459f50301a989a6df1b89358c3a9158c (patch)
treef748a2f2009980ea9d0813e6493d7ed2ce7788df /test
parent5d2944d7b65840766bd8c4efef0af4e2680c0166 (diff)
downloadandroid-node-v8-2a0ec9c6459f50301a989a6df1b89358c3a9158c.tar.gz
android-node-v8-2a0ec9c6459f50301a989a6df1b89358c3a9158c.tar.bz2
android-node-v8-2a0ec9c6459f50301a989a6df1b89358c3a9158c.zip
util: improve inspect's customInspect performance
This improves the performance to copy user options that are then passed through to the custom inspect function. The performance improvement depends on the complexity of the custom inspect function. For very basic cases this is 100% faster than before. PR-URL: https://github.com/nodejs/node/pull/30659 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Michaƫl Zasso <targos@protonmail.com> Reviewed-By: Anto Aravinth <anto.aravinth.cse@gmail.com>
Diffstat (limited to 'test')
-rw-r--r--test/parallel/test-util-inspect.js9
1 files changed, 7 insertions, 2 deletions
diff --git a/test/parallel/test-util-inspect.js b/test/parallel/test-util-inspect.js
index fd699c85f0..0d905b1e72 100644
--- a/test/parallel/test-util-inspect.js
+++ b/test/parallel/test-util-inspect.js
@@ -884,6 +884,10 @@ util.inspect({ hasOwnProperty: null });
assert.strictEqual(opts.budget, undefined);
assert.strictEqual(opts.indentationLvl, undefined);
assert.strictEqual(opts.showHidden, false);
+ assert.deepStrictEqual(
+ new Set(Object.keys(util.inspect.defaultOptions).concat(['stylize'])),
+ new Set(Object.keys(opts))
+ );
opts.showHidden = true;
return { [util.inspect.custom]: common.mustCall((depth, opts2) => {
assert.deepStrictEqual(clone, opts2);
@@ -910,10 +914,11 @@ util.inspect({ hasOwnProperty: null });
}
{
- const subject = { [util.inspect.custom]: common.mustCall((depth) => {
+ const subject = { [util.inspect.custom]: common.mustCall((depth, opts) => {
assert.strictEqual(depth, null);
+ assert.strictEqual(opts.compact, true);
}) };
- util.inspect(subject, { depth: null });
+ util.inspect(subject, { depth: null, compact: true });
}
{