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:
parent
91383e47fd
commit
3cc3e099be
@ -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;
|
||||
|
Loading…
x
Reference in New Issue
Block a user