| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 474e9d6 commit 5bfd13b
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -362,10 +362,13 @@ function formatValue(ctx, value, recurseTimes) { | |||
| 362 | 362 | // Look up the keys of the object. | |
| 363 | 363 | var keys = Object.keys(value); | |
| 364 | 364 | var visibleKeys = arrayToHash(keys); | |
| 365 | + const symbolKeys = Object.getOwnPropertySymbols(value); | ||
| 366 | + const enumSymbolKeys = symbolKeys | ||
| 367 | + .filter((key) => Object.prototype.propertyIsEnumerable.call(value, key)); | ||
| 368 | + keys = keys.concat(enumSymbolKeys); | ||
| 365 | 369 | ||
| 366 | 370 | if (ctx.showHidden) { | |
| 367 | - keys = Object.getOwnPropertyNames(value); | ||
| 368 | - keys = keys.concat(Object.getOwnPropertySymbols(value)); | ||
| 371 | + keys = Object.getOwnPropertyNames(value).concat(symbolKeys); | ||
| 369 | 372 | } | |
| 370 | 373 | ||
| 371 | 374 | // This could be a boxed primitive (new String(), etc.), check valueOf() | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -658,7 +658,9 @@ assert.doesNotThrow(() => { | |||
| 658 | 658 | '{ a: 123, inspect: [Function: inspect] }'); | |
| 659 | 659 | ||
| 660 | 660 | const subject = { a: 123, [util.inspect.custom]() { return this; } }; | |
| 661 | - assert.strictEqual(util.inspect(subject), '{ a: 123 }'); | ||
| 661 | + const UIC = 'util.inspect.custom'; | ||
| 662 | + assert.strictEqual(util.inspect(subject), | ||
| 663 | + `{ a: 123,\n [Symbol(${UIC})]: [Function: [${UIC}]] }`); | ||
| 662 | 664 | } | |
| 663 | 665 | ||
| 664 | 666 | // util.inspect with "colors" option should produce as many lines as without it | |
@@ -725,18 +727,27 @@ if (typeof Symbol !== 'undefined') { | |||
| 725 | 727 | ||
| 726 | 728 | subject[Symbol('symbol')] = 42; | |
| 727 | 729 | ||
| 728 | - assert.strictEqual(util.inspect(subject), '{}'); | ||
| 730 | + assert.strictEqual(util.inspect(subject), '{ [Symbol(symbol)]: 42 }'); | ||
| 729 | 731 | assert.strictEqual( | |
| 730 | 732 | util.inspect(subject, options), | |
| 731 | 733 | '{ [Symbol(symbol)]: 42 }' | |
| 732 | 734 | ); | |
| 733 | 735 | ||
| 736 | + Object.defineProperty( | ||
| 737 | + subject, | ||
| 738 | + Symbol(), | ||
| 739 | + {enumerable: false, value: 'non-enum'}); | ||
| 740 | + assert.strictEqual(util.inspect(subject), '{ [Symbol(symbol)]: 42 }'); | ||
| 741 | + assert.strictEqual( | ||
| 742 | + util.inspect(subject, options), | ||
| 743 | + '{ [Symbol(symbol)]: 42, [Symbol()]: \'non-enum\' }' | ||
| 744 | + ); | ||
| 745 | + | ||
| 734 | 746 | subject = [1, 2, 3]; | |
| 735 | 747 | subject[Symbol('symbol')] = 42; | |
| 736 | 748 | ||
| 737 | - assert.strictEqual(util.inspect(subject), '[ 1, 2, 3 ]'); | ||
| 738 | - assert.strictEqual(util.inspect(subject, options), | ||
| 739 | - '[ 1, 2, 3, [length]: 3, [Symbol(symbol)]: 42 ]'); | ||
| 749 | + assert.strictEqual(util.inspect(subject), | ||
| 750 | + '[ 1, 2, 3, [Symbol(symbol)]: 42 ]'); | ||
| 740 | 751 | } | |
| 741 | 752 | ||
| 742 | 753 | // test Set | |
| Back | FazBrowse Home | New Git URL |
0 commit comments