Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
473 commits
Select commit Hold shift + click to select a range
16283b8
doc: fix argument type of setAAD
tniessen Dec 9, 2019
8d8c05d
http2: forward debug message in debugStreamObj
lundibundi Dec 7, 2019
2155f56
test: disable colorMode in test-console-group
Trott Dec 10, 2019
169a3d5
doc: edit colorMode information
Trott Dec 10, 2019
174e435
tools: update link to google styleguide for cpplint
danbev Dec 10, 2019
2f4615c
doc: clarify build support text
Trott Dec 11, 2019
690deaa
doc: improve doc writable streams: 'finish' event
dev-script Dec 10, 2019
1811b1a
build: fix missing x64 arch suffix in binary tar name
legendecas Dec 10, 2019
17fc4b0
console: unregister temporary error listener
ronag Dec 8, 2019
9b730ad
lib: use strict equality comparison
PW486 Dec 11, 2019
baece55
http: remove unnecessary bind
apapirovski Jun 7, 2019
01bb876
perf_hooks: remove unnecessary bind
apapirovski Jun 7, 2019
91845d8
fs: remove unnecessary bind
apapirovski Jun 7, 2019
dce435d
http2: remove unnecessary bind from setImmediate
apapirovski Jun 7, 2019
f76f143
cluster: remove unnecessary bind
apapirovski Jun 8, 2019
6f61407
src: make debug_options getters public
codebytere Nov 15, 2019
e4b3181
crypto: cast oaepLabel to unsigned char*
codebytere Dec 12, 2019
88085f0
test: improve assertion error message in test-debug-usage
Trott Dec 12, 2019
5a8a7a4
doc: fix description of N-API exception handlers
tniessen Dec 11, 2019
47067ce
tools: enable Markdown linter's usage information
DerekNonGeneric Nov 2, 2019
78cf6d0
build,win: fix goto exit in vcbuild
joaocgreis Dec 13, 2019
4651871
test: avoid leftover report file
Flarna Dec 12, 2019
c554c0e
doc: clarify expectations for PR commit messages
DerekNonGeneric Dec 12, 2019
5cb1744
test: improve dns lookup coverage
KeeReal Dec 3, 2019
9e5d39c
doc: add "Be direct." to the style guide
Trott Dec 13, 2019
9ce788e
process: fix promise catching
pd4d10 Dec 14, 2019
47b5367
benchmark: use let/const instead of var in buffers
dnlup Dec 13, 2019
5537fae
doc: explain napi_run_script
tniessen Dec 9, 2019
732780f
process: refs --unhandled-rejections documentation in warning message
aduh95 Nov 20, 2019
7bfc339
cli: add --trace-exit cli option
legendecas Nov 17, 2019
e6907f0
test: improve test coverage in child_process
juanarbol Feb 24, 2019
1333798
benchmark: update manywrites back pressure
ronag Dec 15, 2019
08186b2
doc: update message.url example in http.IncomingMessage
saitolume Dec 7, 2019
7822eb1
doc: reference worker threads on signal events
legendecas Dec 16, 2019
d04891f
src: fix compiler warning in env.cc
addaleax Dec 18, 2019
3c63af2
src: list used functions on headers
juanarbol Dec 6, 2019
2a2fe8a
test: fix flaky test-http2-client-upload
Flarna Oct 8, 2019
8c3b8e0
benchmark: add clear connections to secure-pair
DiegoTUI May 30, 2019
73701b2
test: fix long lines
cjihrig Dec 18, 2019
334fcbe
dgram: use for...of
trivikr Dec 14, 2019
734b550
test: fix common.enoughTestMem
Trott Dec 20, 2019
3c16855
test: unflake async hooks statwatcher test
lundibundi Nov 10, 2019
9d2e8c5
tools: update ESLint to 6.8.0
cjihrig Dec 20, 2019
ccf1178
deps: V8: cherry-pick d3a1a5b6c491
targos Dec 17, 2019
5622543
src,test: use v8::Global instead of v8::Persistent
addaleax Dec 18, 2019
ea5be29
doc: avoid using v8::Persistent in addon docs
addaleax Dec 18, 2019
b9c057c
tools,src: forbid usage of v8::Persistent
addaleax Dec 18, 2019
2f7bd15
doc: implement minor improvements to BUILDING.md text
Trott Dec 23, 2019
b714e94
tools: fix Raspbian armv7 build
AHgPuK Dec 20, 2019
15adbe8
benchmark: use let instead of var in child_process
dnlup Dec 20, 2019
1f0a1d5
doc: improve doc net:server.listen
dev-script Dec 23, 2019
bfccc00
tls: add PSK support
lundibundi Oct 29, 2018
bbb5707
doc: add unrepresented flags docs for configure
rexagod Jun 5, 2019
5c522dd
doc: standardize usage of hostname vs. host name
Trott Dec 23, 2019
82fbedc
src: port --bash-completion to C++
joyeecheung Feb 3, 2019
2aab93e
doc: fix anchors and subtitle in BUILDING.md
sutangu Nov 6, 2019
9c9138f
test: skip the unsupported test cases for IBM i
dmabupt Dec 6, 2019
86d1998
deps: V8: cherry-pick d406bfd64653
sam-github Dec 9, 2019
d5c0e4d
benchmark: include writev in benchmark
ronag Dec 23, 2019
f08130e
doc: add --enable-source-maps man page entry
cjihrig Dec 24, 2019
b28b16b
doc: add --force-context-aware man page entry
cjihrig Dec 24, 2019
5db6758
doc: add --inspect-publish-uid man page entry
cjihrig Dec 24, 2019
4cd459c
build: fixes build for some os versions
devnexen Oct 27, 2019
8407086
zlib: allow writes after readable 'end' to finish
addaleax Dec 24, 2019
cb35097
src: enable stack trace printing for V8 check failures
addaleax Dec 24, 2019
671a5b7
doc: update parameter type for fs.chmod()
santoshyadavdev Dec 27, 2019
6c9bc3c
doc: improve dns introduction
Trott Dec 25, 2019
9ed7d2e
test: log errors in test-http2-propagate-session-destroy-code
lundibundi Dec 23, 2019
dc8c955
benchmark: replace var with let/const in cluster benchmark
dnlup Dec 20, 2019
54cbbae
doc: update parameter type for fsPromises.chmod()
cjihrig Dec 27, 2019
a5f1434
doc: update mode type for fchmod() functions
cjihrig Dec 27, 2019
5948ff4
doc: update mode type for fs open() functions
cjihrig Dec 27, 2019
cd310e1
doc: update mode type for process.umask()
cjihrig Dec 27, 2019
cb75f56
doc: update mode type for mkdir() functions
cjihrig Dec 27, 2019
17a48f1
fs: use consistent defaults in sync stat functions
cjihrig Dec 26, 2019
91e7c14
doc: fix createDiffieHellman generator type
tniessen Dec 28, 2019
48e1dfe
meta: clarify scope of new nodejs.org issue choice
DerekNonGeneric Dec 28, 2019
bedc6e2
tools: allow the travis commit message job to fail
BridgeAR Dec 27, 2019
25fb34c
doc: de-duplicate security release processes
sam-github Dec 16, 2019
d30911e
benchmark: use let instead of var in crypto
dnlup Dec 30, 2019
e45edab
perf_hooks: move perf_hooks out of experimental
legendecas Dec 26, 2019
7aa7759
doc: clarify role of writable.cork()
GKJCJG Nov 12, 2019
b48cfcc
benchmark: add benchmark on async_hooks enabled http server
legendecas Dec 26, 2019
8ab748e
build: don't use -latomic on macOS
ryandesign Oct 23, 2019
1a0cda1
errors: support prepareSourceMap with source-maps
Dec 31, 2019
7858d65
src: suppress warning in src/node_env_var.cc
HarshithaKP Dec 30, 2019
39dbc10
doc: improve explanation of package.json "type" field
tamias May 1, 2019
4022617
test: use spread object
franher Nov 12, 2019
d905d04
deps: V8: backport a4545db
devnexen Dec 29, 2019
f281946
doc: update REPL documentation to instantiate the REPL
BridgeAR Dec 12, 2019
3fe37e6
https: prevent options object from being mutated
vighnesh153 Jan 2, 2020
b69f2dd
n-api: keep napi_env alive while it has finalizers
addaleax Dec 30, 2019
c6600d1
deps: upgrade http-parser to v2.9.1
sam-github Nov 13, 2019
25f2df4
deps,http: http_parser set max header size to 8KB
mcollina Aug 21, 2018
3a7a3be
http: opt-in insecure HTTP header parsing
sam-github Nov 20, 2019
ccf9038
test: check that --insecure-http-parser works
sam-github Jan 7, 2020
8c5e951
deps: V8: cherry-pick cc5016e1b702
mmarchini Dec 9, 2019
015671d
deps: V8: cherry-pick b38dfaf3a633
mmarchini Dec 9, 2019
6bc2ce2
Revert "src: update v8abbr.h for V8 7.7"
mmarchini Dec 27, 2019
4fd4a73
Revert "test: update postmortem metadata test for V8 7.7"
mmarchini Dec 27, 2019
536d088
stream: use more accurate end-of-stream writable and readable detection
Jan 10, 2020
ee40a00
test: use arrow functions in addons tests
GaryGSC Oct 26, 2019
ac7beba
lib: flatten access to primordials
targos Nov 22, 2019
79dd591
lib: enforce use of Array from primordials
targos Nov 23, 2019
67de744
lib: replace ArrayBuffer.isView by primordial ArrayBuffer
Kawacrepe Nov 27, 2019
61bb7b9
lib: replace Date.now function by primordial DateNow
Tchoupinax Nov 27, 2019
2e81795
lib: enforce use of Boolean from primordials
targos Nov 28, 2019
5de272c
lib: use static Number properties from primordials
targos Nov 27, 2019
d4d6172
lib: enforce use of primordial Number
Sebastien-Ahkrin Nov 28, 2019
c6535c0
lib: replace Symbol global by the primordials Symbol
Sebastien-Ahkrin Nov 30, 2019
54aa3b9
lib: replace every Symbol.for by SymbolFor primordials
Sebastien-Ahkrin Dec 8, 2019
22df5dc
lib: replace Symbol.iterator by SymbolIterator
Sebastien-Ahkrin Dec 8, 2019
d4ea392
lib: enforce use of BigInt from primordials
targos Dec 10, 2019
d1702f5
lib: update Symbol.toStringTag by SymbolToStringTag primordial
Sebastien-Ahkrin Dec 11, 2019
7c3ac42
lib: replace Symbol.toPrimitive to SymbolToPrimitive primordials
Sebastien-Ahkrin Dec 11, 2019
521458a
repl: fix autocomplete when useGlobal is false
targos Dec 10, 2019
b00fcaf
lib: add TypedArray constructors to primordials
Sebastien-Ahkrin Nov 30, 2019
74f7844
v8: use of TypedArray constructors from primordials
Sebastien-Ahkrin Nov 30, 2019
31227e6
lib: enforce use of Promise from primordials
targos Dec 13, 2019
5cfcf6f
lib: replace Symbol.asyncIterator by SymbolAsyncIterator
Sebastien-Ahkrin Dec 13, 2019
581e837
lib: replace Symbol.hasInstance by SymbolHasInstance
Sebastien-Ahkrin Dec 13, 2019
f33147b
lib: replace Symbol.species by SymbolSpecies
Sebastien-Ahkrin Dec 13, 2019
b1550a6
lib: replace Set.prototype with SetPrototype primordial
Sebastien-Ahkrin Jan 2, 2020
90196b8
lib: replace WeakMap global by the primordials
Sebastien-Ahkrin Jan 2, 2020
869cd53
lib: replace WeakSet global by the primordials
Sebastien-Ahkrin Jan 2, 2020
e5b7d64
lib: replace Set global by the primordials
Sebastien-Ahkrin Jan 2, 2020
02ed713
lib: replace use of Error with primordials
Sebastien-Ahkrin Jan 2, 2020
0dd8605
lib: replace Map global by the primordials
Sebastien-Ahkrin Jan 2, 2020
4de6097
module: reduce circular dependency of internal/modules/cjs/loader
joyeecheung Nov 10, 2019
b6ce736
wasi: introduce initial WASI support
cjihrig Sep 4, 2019
78c46c5
build: add --without-node-code-cache configure option
joyeecheung Nov 26, 2019
35ce8bb
build: do not build mksnapshot and mkcodecache for --shared
joyeecheung Nov 26, 2019
4265d57
events: add captureRejection option
mcollina May 19, 2019
fa544c8
stream: add support for captureRejection option
mcollina Aug 19, 2019
cdc33df
http: implement capture rejections for 'request' event
mcollina Sep 3, 2019
99a09a2
http: add captureRejection support to OutgoingMessage
mcollina Sep 20, 2019
5eef00a
net: implement capture rejections for 'connection' event
mcollina Oct 1, 2019
48fcd76
tls: implement capture rejections for 'secureConnection' event
mcollina Oct 1, 2019
2cc0482
http2: implement capture rection for 'request' and 'stream' events
mcollina Oct 2, 2019
81e363a
worker: add argv constructor option
legendecas Nov 20, 2019
11473cc
test: simplify tmpdir import in wasi tests
Trott Dec 2, 2019
8d0217b
test: improve wasi test coverage
Trott Dec 2, 2019
248921b
lib: delay access to CLI option to pre-execution
joyeecheung Dec 3, 2019
e5e60f5
build: remove (almost) unused macros/constants
Dec 1, 2019
d4b41f6
repl: use better uncaught exceptions indicator
BridgeAR Sep 23, 2019
1fbd7ac
util: improve inspect's customInspect performance
BridgeAR Nov 21, 2019
219c8e9
util: add more predefined color codes to inspect.colors
BridgeAR Nov 25, 2019
1f68004
assert,util: stricter type comparison using deep equal comparisons
BridgeAR Dec 2, 2019
2c27df2
test: run more assert tests
BridgeAR Dec 2, 2019
bb8b11f
test: improve WASI options validation
Trott Dec 5, 2019
808a456
src: use checked allocations in WASI::New()
cjihrig Dec 5, 2019
1148724
src: free preopen memory in WASI::New()
cjihrig Dec 5, 2019
5d545d0
deps: update uvwasi
addaleax Dec 1, 2019
2bb364a
wasi: use memory-tracking allocator
addaleax Dec 1, 2019
ec514a6
doc: deprecate http finished
ronag Jul 14, 2019
01ea5ba
lib: replace var with let/const
jens-cappelle Nov 12, 2019
ffc910f
module: fix require in node repl
ZYSzys Dec 7, 2019
76affb6
fs: only operate on buffers in rimraf
cjihrig Nov 20, 2019
fb2253e
fs: retry unlink operations in rimraf
cjihrig Dec 9, 2019
b6688ef
test: use fs rimraf to refresh tmpdir
cjihrig Aug 20, 2019
c3daa3e
fs: synchronize close with other I/O for streams
addaleax Dec 7, 2019
bf9a824
test: wait for stream close before writing to file
addaleax Dec 7, 2019
0638b78
net: remove duplicate _undestroy
ronag Dec 7, 2019
b1358d3
doc: add code example to inspector.url() method
juanarbol Sep 8, 2019
5b78bf2
test: work around ENOTEMPTY when cleaning tmp dir
bnoordhuis Dec 12, 2019
1c6e2ec
lib: refactor NativeModule
joyeecheung Dec 8, 2019
67a2a47
build: auto-load ICU data from --with-icu-default-data-dir
sgallagher Dec 6, 2019
0266d7f
lib: change var to let/const
Dec 12, 2019
8cd8cd7
stream: do not chunk strings and Buffer in Readable.from
mcollina Dec 12, 2019
ace3e70
src: unregister Isolate with platform before disposing
addaleax Dec 12, 2019
7139325
test: add test for validation for wasi.start() argument
Trott Dec 12, 2019
12e9bad
test: add missing test flags
cjihrig Dec 15, 2019
95f332f
readline: promote _getCursorPos to public api
Js-Brecht Nov 27, 2019
f6acf9a
stream: use for...of
trivikr Dec 14, 2019
5d2ae05
wasi: require CLI flag to require() wasi module
cjihrig Dec 14, 2019
299d518
test: improve WASI start() coverage
cjihrig Dec 15, 2019
d676c6c
test: simplify test-wasi-start-validation.js
cjihrig Dec 15, 2019
42ccf22
doc: add note about fs.close() about undefined behavior
ronag Dec 14, 2019
c6be79a
async_hooks: ensure proper handling in runInAsyncScope
apapirovski Dec 14, 2019
ff9b5fc
tls: for...of in _tls_common.js
trivikr Dec 14, 2019
49a9b31
http: use for...of in http library code
trivikr Dec 14, 2019
9da5444
assert: use for...of
soar-beep Dec 16, 2019
8b11954
deps,src,test: update to uvwasi 0.0.3
cjihrig Dec 15, 2019
8be52c4
doc,lib,src,test: rename WASI CLI flag
cjihrig Dec 15, 2019
e4e086a
test: remove obsolete WASI test
cjihrig Dec 15, 2019
62d3beb
events: allow monitoring error events
Flarna Dec 12, 2019
83f02c0
buffer: improve .from() error details
BridgeAR Sep 23, 2019
1c17f42
errors: improve ERR_INVALID_ARG_TYPE
BridgeAR Sep 23, 2019
57f29b7
bootstrap: use different scripts to setup different configurations
joyeecheung Dec 9, 2019
b6c815c
test: cover vm with negative tests
Dec 18, 2019
4198d9a
lib: improve spelling and grammar in comment
datatypevoid Dec 19, 2019
1d45ba3
test: get lib/wasi.js coverage to 100%
cjihrig Dec 20, 2019
b6d09e8
events: add EventEmitter.on to async iterate over events
mcollina May 30, 2019
5dd9fb2
lib: further simplify assertions in vm/module
addaleax Dec 6, 2019
ee9e817
doc,vm,test: remove _sandbox_ from vm documentation
Trott Dec 22, 2019
83f8939
dgram: test to add and to drop specific membership
universePrisoner Dec 20, 2019
a0f5207
stream: simplify isBuf
ronag Dec 23, 2019
a83c976
stream: reset flowing state if no 'readable' or 'data' listeners
ronag Dec 20, 2019
facee2a
timers: do less work in insert
apapirovski Apr 22, 2019
e5c68cd
timers: fix refresh for expired timers
apapirovski Apr 22, 2019
cc3e427
src: prevent hard coding stack trace limit
legendecas Dec 1, 2019
a9d9fdb
deps: uvwasi: cherry-pick 64e59d5
cjihrig Dec 24, 2019
6784296
deps: uvwasi: cherry-pick 75b389c
cjihrig Dec 24, 2019
e815655
wasi: throw on failed uvwasi_init()
cjihrig Dec 22, 2019
c51153c
doc,wasi: use code markup/markdown in headers
Trott Dec 25, 2019
4a7e860
lib: replace var with let/const
kresimirfranin Nov 12, 2019
80d7b6e
wasi: fix serdes bugs from snapshot1 migration
cjihrig Dec 28, 2019
61da657
zlib: use for...of
trivikr Dec 21, 2019
5edfd50
stream: group all properties using defineProperties
antsmartian Dec 31, 2019
b840eb7
http: free listeners on free sockets
ronag Aug 21, 2019
725daeb
http: http_outgoing rename var to let and const
Nov 6, 2019
4bbf584
doc: use code markup/markdown in headers
BridgeAR Jan 1, 2020
625ed70
doc: remove extra backtick
cjihrig Jan 4, 2020
4a1cb3d
lib: do not catch user errors
BridgeAR Jan 1, 2020
59e2975
perf_hooks: use for...of
trivikr Dec 21, 2019
20a8175
http2: set default enableConnectProtocol to 0
ZYSzys Jan 3, 2020
18cd002
test: change buffer offset to accommodate V8 BackingStore
thangktran Dec 24, 2019
4ee5665
benchmark: use let instead of var in dgram
dnlup Jan 3, 2020
ff47915
wasi: refactor destructuring object on constructor
himself65 Jan 4, 2020
69eaff1
lib: move initialization of APIs for changing process state
addaleax Jan 3, 2020
4c1d172
src: mark ArrayBuffers with free callbacks as untransferable
addaleax Nov 13, 2019
8252c06
buffer: release buffers with free callbacks on env exit
addaleax Nov 19, 2019
09e4182
deps: V8: cherry-pick d89f4ef1cd62
Jan 14, 2020
cad0402
module: loader getSource, getFormat, transform hooks
GeoffreyBooth Dec 15, 2019
fae517a
module: logical conditional exports ordering
guybedford Dec 17, 2019
616a4ee
module: unflag conditional exports
guybedford Dec 17, 2019
db5ec52
module: fix check exports issue in cjs module loading
guybedford Jan 20, 2020
ad4af04
test,module: add test for exports cjs loader check
Trott Jan 21, 2020
02d7283
deps: V8: cherry-pick 0dfd9ea51241
Jan 19, 2020
f63e440
http2: make HTTP2ServerResponse more streams compliant
ronag Dec 14, 2019
ea3d4e8
n-api: implement napi_is_detached_arraybuffer
lundibundi Nov 23, 2019
a1ce776
util: fix .format() not always calling toString when it should be
BridgeAR Nov 9, 2019
a1555cb
benchmark: add more util inspect and format benchmarks
BridgeAR Nov 30, 2019
a309ee1
util: improve performance inspecting proxies
BridgeAR Nov 30, 2019
bbf39bc
util: never trigger any proxy traps using `format()`
BridgeAR Dec 1, 2019
40a724c
util: fix built-in detection
BridgeAR Nov 30, 2019
b0e3aec
util: inspect (user defined) prototype properties
BridgeAR Nov 30, 2019
3b9360d
util: refactor inspect code for constistency
BridgeAR Nov 2, 2019
cc19d08
util: add (typed) array length to the default output
BridgeAR Dec 19, 2019
6f5ced6
src: accept single argument in getProxyDetails
BridgeAR Dec 8, 2019
fc0febe
util: improve prototype inspection using `inspect()` and `showHidden`
BridgeAR Dec 26, 2019
e938784
assert: fix generatedMessage property
BridgeAR Jun 14, 2019
881ebce
assert: DRY .throws code
BridgeAR Jun 14, 2019
6d8a541
doc: update assert.throws() examples
BridgeAR Jun 17, 2019
5c6a6b8
doc: make `AssertionError` a link
BridgeAR Jun 20, 2019
67ec97a
assert: implement `assert.match()` and `assert.doesNotMatch()`
BridgeAR Dec 12, 2019
b9d15b3
2020-02-12, Version 12.15.0 'Erbium' (LTS)
targos Jan 14, 2020
905d8ff
wip notable changes
targos Jan 17, 2020
8ad9952
fixup: update changelog
MylesBorins Jan 30, 2020
dc5c052
fixup: add moar commits
MylesBorins Jan 30, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
util: inspect (user defined) prototype properties
This is only active if the `showHidden` option is truthy.

The implementation is a trade-off between accuracy and performance.
This will miss properties such as properties added to built-in data
types.

The goal is mainly to visualize prototype getters and setters such as:

class Foo {
  ownProperty = true
  get bar() {
    return 'Hello world!'
  }
}

const a = new Foo()

The `bar` property is a non-enumerable property on the prototype while
`ownProperty` will be set directly on the created instance.

The output is similar to the one of Chromium when inspecting objects
closer. The output from Firefox is difficult to compare, since it's
always a structured interactive output and was therefore not taken
into account.

Backport-PR-URL: #31431
PR-URL: #30768
Fixes: #30183
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
  • Loading branch information
BridgeAR authored and MylesBorins committed Jan 30, 2020
commit b0e3aec7ca09630a69e023927c00314cc7094c1a
7 changes: 6 additions & 1 deletion doc/api/util.md
Original file line number Diff line number Diff line change
Expand Up @@ -398,6 +398,10 @@ stream.write('With ES6');
<!-- YAML
added: v0.3.0
changes:
- version: REPLACEME
pr-url: https://github.com/nodejs/node/pull/30768
description: User defined prototype properties are inspected in case
`showHidden` is `true`.
- version: v12.0.0
pr-url: https://github.com/nodejs/node/pull/27109
description: The `compact` options default is changed to `3` and the
Expand Down Expand Up @@ -458,7 +462,8 @@ changes:
* `options` {Object}
* `showHidden` {boolean} If `true`, `object`'s non-enumerable symbols and
properties are included in the formatted result. [`WeakMap`][] and
[`WeakSet`][] entries are also included. **Default:** `false`.
[`WeakSet`][] entries are also included as well as user defined prototype
properties (excluding method properties). **Default:** `false`.
* `depth` {number} Specifies the number of times to recurse while formatting
`object`. This is useful for inspecting large objects. To recurse up to
the maximum call stack size pass `Infinity` or `null`.
Expand Down
116 changes: 100 additions & 16 deletions lib/internal/util/inspect.js
Original file line number Diff line number Diff line change
Expand Up @@ -450,14 +450,20 @@ function getEmptyFormatArray() {
return [];
}

function getConstructorName(obj, ctx, recurseTimes) {
function getConstructorName(obj, ctx, recurseTimes, protoProps) {
let firstProto;
const tmp = obj;
while (obj) {
const descriptor = ObjectGetOwnPropertyDescriptor(obj, 'constructor');
if (descriptor !== undefined &&
typeof descriptor.value === 'function' &&
descriptor.value.name !== '') {
if (protoProps !== undefined &&
!builtInObjects.has(descriptor.value.name)) {
const isProto = firstProto !== undefined;
addPrototypeProperties(
ctx, tmp, obj, recurseTimes, isProto, protoProps);
}
return descriptor.value.name;
}

Expand All @@ -477,7 +483,8 @@ function getConstructorName(obj, ctx, recurseTimes) {
return `${res} <Complex prototype>`;
}

const protoConstr = getConstructorName(firstProto, ctx, recurseTimes + 1);
const protoConstr = getConstructorName(
firstProto, ctx, recurseTimes + 1, protoProps);

if (protoConstr === null) {
return `${res} <${inspect(firstProto, {
Expand All @@ -490,6 +497,68 @@ function getConstructorName(obj, ctx, recurseTimes) {
return `${res} <${protoConstr}>`;
}

// This function has the side effect of adding prototype properties to the
// `output` argument (which is an array). This is intended to highlight user
// defined prototype properties.
function addPrototypeProperties(ctx, main, obj, recurseTimes, isProto, output) {
let depth = 0;
let keys;
let keySet;
do {
if (!isProto) {
obj = ObjectGetPrototypeOf(obj);
// Stop as soon as a null prototype is encountered.
if (obj === null) {
return;
}
// Stop as soon as a built-in object type is detected.
const descriptor = ObjectGetOwnPropertyDescriptor(obj, 'constructor');
if (descriptor !== undefined &&
typeof descriptor.value === 'function' &&
builtInObjects.has(descriptor.value.name)) {
return;
}
} else {
isProto = false;
}

if (depth === 0) {
keySet = new Set();
} else {
keys.forEach((key) => keySet.add(key));
}
// Get all own property names and symbols.
keys = ObjectGetOwnPropertyNames(obj);
const symbols = ObjectGetOwnPropertySymbols(obj);
if (symbols.length !== 0) {
keys.push(...symbols);
}
for (const key of keys) {
// Ignore the `constructor` property and keys that exist on layers above.
if (key === 'constructor' ||
ObjectPrototypeHasOwnProperty(main, key) ||
(depth !== 0 && keySet.has(key))) {
continue;
}
const desc = ObjectGetOwnPropertyDescriptor(obj, key);
if (typeof desc.value === 'function') {
continue;
}
const value = formatProperty(
ctx, obj, recurseTimes, key, kObjectType, desc);
if (ctx.colors) {
// Faint!
output.push(`\u001b[2m${value}\u001b[22m`);
} else {
output.push(value);
}
}
// Limit the inspection to up to three prototype layers. Using `recurseTimes`
// is not a good choice here, because it's as if the properties are declared
// on the current object from the users perspective.
} while (++depth !== 3);
}

function getPrefix(constructor, tag, fallback) {
if (constructor === null) {
if (tag !== '') {
Expand Down Expand Up @@ -693,8 +762,17 @@ function formatValue(ctx, value, recurseTimes, typedArray) {

function formatRaw(ctx, value, recurseTimes, typedArray) {
let keys;
let protoProps;
if (ctx.showHidden && (recurseTimes <= ctx.depth || ctx.depth === null)) {
protoProps = [];
}

const constructor = getConstructorName(value, ctx, recurseTimes, protoProps);
// Reset the variable to check for this later on.
if (protoProps !== undefined && protoProps.length === 0) {
protoProps = undefined;
}

const constructor = getConstructorName(value, ctx, recurseTimes);
let tag = value[SymbolToStringTag];
// Only list the tag in case it's non-enumerable / not an own property.
// Otherwise we'd print this twice.
Expand Down Expand Up @@ -724,21 +802,21 @@ function formatRaw(ctx, value, recurseTimes, typedArray) {
// Only set the constructor for non ordinary ("Array [...]") arrays.
const prefix = getPrefix(constructor, tag, 'Array');
braces = [`${prefix === 'Array ' ? '' : prefix}[`, ']'];
if (value.length === 0 && keys.length === 0)
if (value.length === 0 && keys.length === 0 && protoProps === undefined)
return `${braces[0]}]`;
extrasType = kArrayExtrasType;
formatter = formatArray;
} else if (isSet(value)) {
keys = getKeys(value, ctx.showHidden);
const prefix = getPrefix(constructor, tag, 'Set');
if (value.size === 0 && keys.length === 0)
if (value.size === 0 && keys.length === 0 && protoProps === undefined)
return `${prefix}{}`;
braces = [`${prefix}{`, '}'];
formatter = formatSet;
} else if (isMap(value)) {
keys = getKeys(value, ctx.showHidden);
const prefix = getPrefix(constructor, tag, 'Map');
if (value.size === 0 && keys.length === 0)
if (value.size === 0 && keys.length === 0 && protoProps === undefined)
return `${prefix}{}`;
braces = [`${prefix}{`, '}'];
formatter = formatMap;
Expand Down Expand Up @@ -773,12 +851,12 @@ function formatRaw(ctx, value, recurseTimes, typedArray) {
} else if (tag !== '') {
braces[0] = `${getPrefix(constructor, tag, 'Object')}{`;
}
if (keys.length === 0) {
if (keys.length === 0 && protoProps === undefined) {
return `${braces[0]}}`;
}
} else if (typeof value === 'function') {
base = getFunctionBase(value, constructor, tag);
if (keys.length === 0)
if (keys.length === 0 && protoProps === undefined)
return ctx.stylize(base, 'special');
} else if (isRegExp(value)) {
// Make RegExps say that they are RegExps
Expand All @@ -788,8 +866,10 @@ function formatRaw(ctx, value, recurseTimes, typedArray) {
const prefix = getPrefix(constructor, tag, 'RegExp');
if (prefix !== 'RegExp ')
base = `${prefix}${base}`;
if (keys.length === 0 || (recurseTimes > ctx.depth && ctx.depth !== null))
if ((keys.length === 0 && protoProps === undefined) ||
(recurseTimes > ctx.depth && ctx.depth !== null)) {
return ctx.stylize(base, 'regexp');
}
} else if (isDate(value)) {
// Make dates with properties first say the date
base = NumberIsNaN(DatePrototypeGetTime(value)) ?
Expand All @@ -798,12 +878,12 @@ function formatRaw(ctx, value, recurseTimes, typedArray) {
const prefix = getPrefix(constructor, tag, 'Date');
if (prefix !== 'Date ')
base = `${prefix}${base}`;
if (keys.length === 0) {
if (keys.length === 0 && protoProps === undefined) {
return ctx.stylize(base, 'date');
}
} else if (isError(value)) {
base = formatError(value, constructor, tag, ctx);
if (keys.length === 0)
if (keys.length === 0 && protoProps === undefined)
return base;
} else if (isAnyArrayBuffer(value)) {
// Fast path for ArrayBuffer and SharedArrayBuffer.
Expand All @@ -814,7 +894,7 @@ function formatRaw(ctx, value, recurseTimes, typedArray) {
const prefix = getPrefix(constructor, tag, arrayType);
if (typedArray === undefined) {
formatter = formatArrayBuffer;
} else if (keys.length === 0) {
} else if (keys.length === 0 && protoProps === undefined) {
return prefix +
`{ byteLength: ${formatNumber(ctx.stylize, value.byteLength)} }`;
}
Expand All @@ -838,7 +918,7 @@ function formatRaw(ctx, value, recurseTimes, typedArray) {
formatter = formatNamespaceObject;
} else if (isBoxedPrimitive(value)) {
base = getBoxedBase(value, ctx, keys, constructor, tag);
if (keys.length === 0) {
if (keys.length === 0 && protoProps === undefined) {
return base;
}
} else {
Expand All @@ -858,7 +938,7 @@ function formatRaw(ctx, value, recurseTimes, typedArray) {
formatter = formatIterator;
// Handle other regular objects again.
} else {
if (keys.length === 0) {
if (keys.length === 0 && protoProps === undefined) {
if (isExternal(value))
return ctx.stylize('[External]', 'special');
return `${getCtxStyle(value, constructor, tag)}{}`;
Expand Down Expand Up @@ -886,6 +966,9 @@ function formatRaw(ctx, value, recurseTimes, typedArray) {
output.push(
formatProperty(ctx, value, recurseTimes, keys[i], extrasType));
}
if (protoProps !== undefined) {
output.push(...protoProps);
}
} catch (err) {
const constructorName = getCtxStyle(value, constructor, tag).slice(0, -1);
return handleMaxCallStackSize(ctx, err, constructorName, indentationLvl);
Expand Down Expand Up @@ -1349,6 +1432,7 @@ function formatTypedArray(ctx, value, recurseTimes) {
}
if (ctx.showHidden) {
// .buffer goes last, it's not a primitive like the others.
// All besides `BYTES_PER_ELEMENT` are actually getters.
ctx.indentationLvl += 2;
for (const key of [
'BYTES_PER_ELEMENT',
Expand Down Expand Up @@ -1497,10 +1581,10 @@ function formatPromise(ctx, value, recurseTimes) {
return output;
}

function formatProperty(ctx, value, recurseTimes, key, type) {
function formatProperty(ctx, value, recurseTimes, key, type, desc) {
let name, str;
let extra = ' ';
const desc = ObjectGetOwnPropertyDescriptor(value, key) ||
desc = desc || ObjectGetOwnPropertyDescriptor(value, key) ||
{ value: value[key], enumerable: true };
if (desc.value !== undefined) {
const diff = (type !== kObjectType || ctx.compact !== true) ? 2 : 3;
Expand Down
80 changes: 79 additions & 1 deletion test/parallel/test-util-inspect.js
Original file line number Diff line number Diff line change
Expand Up @@ -391,8 +391,24 @@ assert.strictEqual(
{
class CustomArray extends Array {}
CustomArray.prototype[5] = 'foo';
CustomArray.prototype[49] = 'bar';
CustomArray.prototype.foo = true;
const arr = new CustomArray(50);
assert.strictEqual(util.inspect(arr), 'CustomArray [ <50 empty items> ]');
arr[49] = 'I win';
assert.strictEqual(
util.inspect(arr),
"CustomArray [ <49 empty items>, 'I win' ]"
);
assert.strictEqual(
util.inspect(arr, { showHidden: true }),
'CustomArray [\n' +
' <49 empty items>,\n' +
" 'I win',\n" +
' [length]: 50,\n' +
" '5': 'foo',\n" +
' foo: true\n' +
']'
);
}

// Array with extra properties.
Expand Down Expand Up @@ -2585,3 +2601,65 @@ assert.strictEqual(
throw err;
}
}

// Inspect prototype properties.
{
class Foo extends Map {
prop = false;
prop2 = true;
get abc() {
return true;
}
get def() {
return false;
}
set def(v) {}
get xyz() {
return 'Should be ignored';
}
func(a) {}
[util.inspect.custom]() {
return this;
}
}

class Bar extends Foo {
abc = true;
prop = true;
get xyz() {
return 'YES!';
}
[util.inspect.custom]() {
return this;
}
}

const bar = new Bar();

assert.strictEqual(
inspect(bar),
'Bar [Map] { prop: true, prop2: true, abc: true }'
);
assert.strictEqual(
inspect(bar, { showHidden: true, getters: true, colors: false }),
'Bar [Map] {\n' +
' [size]: 0,\n' +
' prop: true,\n' +
' prop2: true,\n' +
' abc: true,\n' +
" [xyz]: [Getter: 'YES!'],\n" +
' [def]: [Getter/Setter: false]\n' +
'}'
);
assert.strictEqual(
inspect(bar, { showHidden: true, getters: false, colors: true }),
'Bar [Map] {\n' +
' [size]: \x1B[33m0\x1B[39m,\n' +
' prop: \x1B[33mtrue\x1B[39m,\n' +
' prop2: \x1B[33mtrue\x1B[39m,\n' +
' abc: \x1B[33mtrue\x1B[39m,\n' +
' \x1B[2m[xyz]: \x1B[36m[Getter]\x1B[39m\x1B[22m,\n' +
' \x1B[2m[def]: \x1B[36m[Getter/Setter]\x1B[39m\x1B[22m\n' +
'}'
);
}
17 changes: 13 additions & 4 deletions test/parallel/test-whatwg-encoding-custom-textdecoder.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,10 +113,19 @@ if (common.hasIntl) {
} else {
assert.strictEqual(
util.inspect(dec, { showHidden: true }),
"TextDecoder {\n encoding: 'utf-8',\n fatal: false,\n " +
'ignoreBOM: true,\n [Symbol(flags)]: 4,\n [Symbol(handle)]: ' +
"StringDecoder {\n encoding: 'utf8',\n " +
'[Symbol(kNativeDecoder)]: <Buffer 00 00 00 00 00 00 01>\n }\n}'
'TextDecoder {\n' +
" encoding: 'utf-8',\n" +
' fatal: false,\n' +
' ignoreBOM: true,\n' +
' [Symbol(flags)]: 4,\n' +
' [Symbol(handle)]: StringDecoder {\n' +
" encoding: 'utf8',\n" +
' [Symbol(kNativeDecoder)]: <Buffer 00 00 00 00 00 00 01>,\n' +
' lastChar: [Getter],\n' +
' lastNeed: [Getter],\n' +
' lastTotal: [Getter]\n' +
' }\n' +
'}'
);
}
}
Expand Down