diff options
author | Ruben Bridgewater <ruben@bridgewater.de> | 2019-02-22 23:26:25 +0100 |
---|---|---|
committer | Ruben Bridgewater <ruben@bridgewater.de> | 2019-03-01 00:04:15 +0100 |
commit | 4db10ed9ad41764eab40df714d761389bbaf6df3 (patch) | |
tree | a20a4731a3d3906a0a95e372ba35546f184fdcf9 /test | |
parent | f4257a2af1a269627ccbd425e026d9bd76491a8f (diff) | |
download | android-node-v8-4db10ed9ad41764eab40df714d761389bbaf6df3.tar.gz android-node-v8-4db10ed9ad41764eab40df714d761389bbaf6df3.tar.bz2 android-node-v8-4db10ed9ad41764eab40df714d761389bbaf6df3.zip |
util: add compact depth mode
This overloads the `compact` option from `util.inspect()`. If it's
set to a number, it is going to align all most inner entries on the
same lign if they adhere to the following:
* The entries do not exceed the `breakLength` options value.
* The entry is one of the local most inner levels up the the one
provided in `compact`.
PR-URL: https://github.com/nodejs/node/pull/26269
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Diffstat (limited to 'test')
-rw-r--r-- | test/parallel/test-util-inspect.js | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/test/parallel/test-util-inspect.js b/test/parallel/test-util-inspect.js index 4e9f5ac004..fdba7ebe1b 100644 --- a/test/parallel/test-util-inspect.js +++ b/test/parallel/test-util-inspect.js @@ -1498,6 +1498,42 @@ util.inspect(process); assert.strict.equal(out, expected); + out = util.inspect(map, { compact: 2, showHidden: true, depth: 9 }); + + expected = [ + 'Map {', + ' Promise {', + ' [', + ' [', + ' 1,', + ' Set { [ 1, 2, [length]: 2 ], [size]: 1 },', + ' [length]: 2', + ' ],', + ' [length]: 1', + ' ]', + ' } => Uint8Array [', + ' [BYTES_PER_ELEMENT]: 1,', + ' [length]: 0,', + ' [byteLength]: 0,', + ' [byteOffset]: 0,', + ' [buffer]: ArrayBuffer { byteLength: 0, foo: true }', + ' ],', + ' [Set Iterator] { [ 1, 2, [length]: 2 ] } => [Map Iterator] {', + ' Uint8Array [', + ' [BYTES_PER_ELEMENT]: 1,', + ' [length]: 0,', + ' [byteLength]: 0,', + ' [byteOffset]: 0,', + ' [buffer]: ArrayBuffer { byteLength: 0, foo: true }', + ' ],', + ' [Circular]', + ' },', + ' [size]: 2', + '}' + ].join('\n'); + + assert.strict.equal(out, expected); + out = util.inspect(map, { showHidden: true, depth: 9, breakLength: 4 }); expected = [ 'Map {', |