| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 9b7cf09 commit 697908e
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -465,10 +465,10 @@ function getConstructorName(obj, ctx, recurseTimes, protoProps) { | |||
| 465 | 465 | typeof descriptor.value === 'function' && | |
| 466 | 466 | descriptor.value.name !== '') { | |
| 467 | 467 | if (protoProps !== undefined && | |
| 468 | - !builtInObjects.has(descriptor.value.name)) { | ||
| 469 | - const isProto = firstProto !== undefined; | ||
| 468 | + (firstProto !== obj || | ||
| 469 | + !builtInObjects.has(descriptor.value.name))) { | ||
| 470 | 470 | addPrototypeProperties( | |
| 471 | - ctx, tmp, obj, recurseTimes, isProto, protoProps); | ||
| 471 | + ctx, tmp, firstProto || tmp, recurseTimes, protoProps); | ||
| 472 | 472 | } | |
| 473 | 473 | return descriptor.value.name; | |
| 474 | 474 | } | |
@@ -506,12 +506,12 @@ function getConstructorName(obj, ctx, recurseTimes, protoProps) { | |||
| 506 | 506 | // This function has the side effect of adding prototype properties to the | |
| 507 | 507 | // `output` argument (which is an array). This is intended to highlight user | |
| 508 | 508 | // defined prototype properties. | |
| 509 | - function addPrototypeProperties(ctx, main, obj, recurseTimes, isProto, output) { | ||
| 509 | + function addPrototypeProperties(ctx, main, obj, recurseTimes, output) { | ||
| 510 | 510 | let depth = 0; | |
| 511 | 511 | let keys; | |
| 512 | 512 | let keySet; | |
| 513 | 513 | do { | |
| 514 | - if (!isProto) { | ||
| 514 | + if (depth !== 0 || main === obj) { | ||
| 515 | 515 | obj = ObjectGetPrototypeOf(obj); | |
| 516 | 516 | // Stop as soon as a null prototype is encountered. | |
| 517 | 517 | if (obj === null) { | |
@@ -524,8 +524,6 @@ function addPrototypeProperties(ctx, main, obj, recurseTimes, isProto, output) { | |||
| 524 | 524 | builtInObjects.has(descriptor.value.name)) { | |
| 525 | 525 | return; | |
| 526 | 526 | } | |
| 527 | - } else { | ||
| 528 | - isProto = false; | ||
| 529 | 527 | } | |
| 530 | 528 | ||
| 531 | 529 | if (depth === 0) { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1695,7 +1695,8 @@ util.inspect(process); | |||
| 1695 | 1695 | ' 1,', | |
| 1696 | 1696 | ' 2,', | |
| 1697 | 1697 | ' [length]: 2', | |
| 1698 | - ' ]', | ||
| 1698 | + ' ],', | ||
| 1699 | + " [Symbol(Symbol.toStringTag)]: 'Set Iterator'", | ||
| 1699 | 1700 | ' } => <ref *1> [Map Iterator] {', | |
| 1700 | 1701 | ' Uint8Array(0) [', | |
| 1701 | 1702 | ' [BYTES_PER_ELEMENT]: 1,', | |
@@ -1707,7 +1708,8 @@ util.inspect(process); | |||
| 1707 | 1708 | ' foo: true', | |
| 1708 | 1709 | ' }', | |
| 1709 | 1710 | ' ],', | |
| 1710 | - ' [Circular *1]', | ||
| 1711 | + ' [Circular *1],', | ||
| 1712 | + " [Symbol(Symbol.toStringTag)]: 'Map Iterator'", | ||
| 1711 | 1713 | ' }', | |
| 1712 | 1714 | '}' | |
| 1713 | 1715 | ].join('\n'); | |
@@ -1734,15 +1736,19 @@ util.inspect(process); | |||
| 1734 | 1736 | ' [byteOffset]: 0,', | |
| 1735 | 1737 | ' [buffer]: ArrayBuffer { byteLength: 0, foo: true }', | |
| 1736 | 1738 | ' ],', | |
| 1737 | - ' [Set Iterator] { [ 1, 2, [length]: 2 ] } => <ref *1> [Map Iterator] {', | ||
| 1739 | + ' [Set Iterator] {', | ||
| 1740 | + ' [ 1, 2, [length]: 2 ],', | ||
| 1741 | + " [Symbol(Symbol.toStringTag)]: 'Set Iterator'", | ||
| 1742 | + ' } => <ref *1> [Map Iterator] {', | ||
| 1738 | 1743 | ' Uint8Array(0) [', | |
| 1739 | 1744 | ' [BYTES_PER_ELEMENT]: 1,', | |
| 1740 | 1745 | ' [length]: 0,', | |
| 1741 | 1746 | ' [byteLength]: 0,', | |
| 1742 | 1747 | ' [byteOffset]: 0,', | |
| 1743 | 1748 | ' [buffer]: ArrayBuffer { byteLength: 0, foo: true }', | |
| 1744 | 1749 | ' ],', | |
| 1745 | - ' [Circular *1]', | ||
| 1750 | + ' [Circular *1],', | ||
| 1751 | + " [Symbol(Symbol.toStringTag)]: 'Map Iterator'", | ||
| 1746 | 1752 | ' }', | |
| 1747 | 1753 | '}' | |
| 1748 | 1754 | ].join('\n'); | |
@@ -1772,7 +1778,9 @@ util.inspect(process); | |||
| 1772 | 1778 | ' [Set Iterator] {', | |
| 1773 | 1779 | ' [ 1,', | |
| 1774 | 1780 | ' 2,', | |
| 1775 | - ' [length]: 2 ] } => <ref *1> [Map Iterator] {', | ||
| 1781 | + ' [length]: 2 ],', | ||
| 1782 | + ' [Symbol(Symbol.toStringTag)]:', | ||
| 1783 | + " 'Set Iterator' } => <ref *1> [Map Iterator] {", | ||
| 1776 | 1784 | ' Uint8Array(0) [', | |
| 1777 | 1785 | ' [BYTES_PER_ELEMENT]: 1,', | |
| 1778 | 1786 | ' [length]: 0,', | |
@@ -1781,7 +1789,9 @@ util.inspect(process); | |||
| 1781 | 1789 | ' [buffer]: ArrayBuffer {', | |
| 1782 | 1790 | ' byteLength: 0,', | |
| 1783 | 1791 | ' foo: true } ],', | |
| 1784 | - ' [Circular *1] } }' | ||
| 1792 | + ' [Circular *1],', | ||
| 1793 | + ' [Symbol(Symbol.toStringTag)]:', | ||
| 1794 | + " 'Map Iterator' } }" | ||
| 1785 | 1795 | ].join('\n'); | |
| 1786 | 1796 | ||
| 1787 | 1797 | assert.strict.equal(out, expected); | |
@@ -2680,4 +2690,11 @@ assert.strictEqual( | |||
| 2680 | 2690 | ' \x1B[2m[def]: \x1B[36m[Getter/Setter]\x1B[39m\x1B[22m\n' + | |
| 2681 | 2691 | '}' | |
| 2682 | 2692 | ); | |
| 2693 | + | ||
| 2694 | + const obj = Object.create({ abc: true, def: 5, toString() {} }); | ||
| 2695 | + assert.strictEqual( | ||
| 2696 | + inspect(obj, { showHidden: true, colors: true }), | ||
| 2697 | + '{ \x1B[2mabc: \x1B[33mtrue\x1B[39m\x1B[22m, ' + | ||
| 2698 | + '\x1B[2mdef: \x1B[33m5\x1B[39m\x1B[22m }' | ||
| 2699 | + ); | ||
| 2683 | 2700 | } | |
| Back | FazBrowse Home | New Git URL |
0 commit comments