8000
We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 7696d1f commit a333272Copy full SHA for a333272
lib/internal/util/inspect.js
@@ -211,34 +211,34 @@ Object.defineProperty(inspect, 'defaultOptions', {
211
212
// http://en.wikipedia.org/wiki/ANSI_escape_code#graphics
213
inspect.colors = Object.assign(Object.create(null), {
214
- 'bold': [1, 22],
215
- 'italic': [3, 23],
216
- 'underline': [4, 24],
217
- 'inverse': [7, 27],
218
- 'white': [37, 39],
219
- 'grey': [90, 39],
220
- 'black': [30, 39],
221
- 'blue': [34, 39],
222
- 'cyan': [36, 39],
223
- 'green': [32, 39],
224
- 'magenta': [35, 39],
225
- 'red': [31, 39],
226
- 'yellow': [33, 39]
+ bold: [1, 22],
+ italic: [3, 23],
+ underline: [4, 24],
+ inverse: [7, 27],
+ white: [37, 39],
+ grey: [90, 39],
+ black: [30, 39],
+ blue: [34, 39],
+ cyan: [36, 39],
+ green: [32, 39],
+ magenta: [35, 39],
+ red: [31, 39],
+ yellow: [33, 39]
227
});
228
229
// Don't use 'blue' not visible on cmd.exe
230
inspect.styles = Object.assign(Object.create(null), {
231
- 'special': 'cyan',
232
- 'number': 'yellow',
233
- 'bigint': 'yellow',
234
- 'boolean': 'yellow',
235
- 'undefined': 'grey',
236
- 'null': 'bold',
237
- 'string': 'green',
238
- 'symbol': 'green',
239
- 'date': 'magenta',
+ special: 'cyan',
+ number: 'yellow',
+ bigint: 'yellow',
+ boolean: 'yellow',
+ undefined: 'grey',
+ null: 'bold',
+ string: 'green',
+ symbol: 'green',
+ date: 'magenta',
240
// "name": intentionally not styling
241
- 'regexp': 'red'
+ regexp: 'red'
242
243
244
function addQuotes(str, quotes) {
@@ -358,14 +358,10 @@ function getPrefix(constructor, tag, fallback) {
358
return `[${fallback}: null prototype] `;
359
}
360
361
- if (constructor !== '') {
362
- if (tag !== '' && constructor !== tag) {
363
- return `${constructor} [${tag}] `;
364
- }
365
- return `${constructor} `;
+ if (tag !== '' && constructor !== tag) {
+ return `${constructor} [${tag}] `;
366
367
-
368
- return '';
+ return `${constructor} `;
369
370
371
const getBoxedValue = formatPrimitive.bind(null, stylizeNoColor);
@@ -619,16 +615,12 @@ function formatRaw(ctx, value, recurseTimes, typedArray) {
619
615
braces = ['{', '}'];
620
616
if (constructor === 'Object') {
621
617
if (isArgumentsObject(value)) {
622
- if (keys.length === 0)
623
- return '[Arguments] {}';
624
618
braces[0] = '[Arguments] {';
625
} else if (tag !== '') {
626
braces[0] = `${getPrefix(constructor, tag, 'Object')}{`;
627
- if (keys.length === 0) {
628
- return `${braces[0]}}`;
629
630
- } else if (keys.length === 0) {
631
- return '{}';
+ }
+ if (keys.length === 0) {
+ return `${braces[0]}}`;
632
633
} else if (typeof value === 'function') {
634
const type = constructor || tag || 'Function';
@@ -822,9 +814,7 @@ function handleMaxCallStackSize(ctx, err, constructor, tag, indentationLvl) {
822
814
823
815
function formatNumber(fn, value) {
824
816
// Format -0 as '-0'. Checking `value === -0` won't distinguish 0 from -0.
825
- if (Object.is(value, -0))
826
- return fn('-0', 'number');
827
- return fn(`${value}`, 'number');
817
+ return fn(Object.is(value, -0) ? '-0' : `${value}`, 'number');
828
818
829
819
830
820
function formatBigInt(fn, value) {
test/parallel/test-util-inspect.js
@@ -1853,7 +1853,6 @@ assert.strictEqual(
1853
util.inspect(new StorageObject()),
1854
'<[Object: null prototype] {}> {}'
1855
);
1856
1857
1858
1859
// Check that the fallback always works.