mirror of
https://github.com/nodejs/node.git
synced 2026-11-29 14:27:57 -05:00
util: show External values explicitly in inspect
Display `v8::External` values as `[External]` rather than `{}`
which makes them look like objects.
PR-URL: https://github.com/nodejs/node/pull/12151
Reviewed-By: Timothy Gu <timothygu99@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
This commit is contained in:
3 files changed
+7
No files matched your search
@@ -466,6 +466,9 @@ function formatValue(ctx, value, recurseTimes) {
|
||||
return `${constructor.name}` +
|
||||
` { byteLength: ${formatNumber(ctx, value.byteLength)} }`;
|
||||
}
|
||||
if (binding.isExternal(value)) {
|
||||
return ctx.stylize('[External]', 'special');
|
||||
}
|
||||
}
|
||||
|
||||
var base = '';
|
||||
|
||||
@@ -22,6 +22,7 @@ using v8::Value;
|
||||
V(isArrayBuffer, IsArrayBuffer) \
|
||||
V(isDataView, IsDataView) \
|
||||
V(isDate, IsDate) \
|
||||
V(isExternal, IsExternal) \
|
||||
V(isMap, IsMap) \
|
||||
V(isMapIterator, IsMapIterator) \
|
||||
V(isPromise, IsPromise) \
|
||||
|
||||
@@ -82,6 +82,9 @@ assert.strictEqual(util.inspect(Object.assign(new String('hello'),
|
||||
{ [Symbol('foo')]: 123 }), { showHidden: true }),
|
||||
'{ [String: \'hello\'] [length]: 5, [Symbol(foo)]: 123 }');
|
||||
|
||||
assert.strictEqual(util.inspect(process.stdin._handle._externalStream),
|
||||
'[External]');
|
||||
|
||||
{
|
||||
const regexp = /regexp/;
|
||||
regexp.aprop = 42;
|
||||
|
||||
Reference in new issue
Block a user