| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 6f5ced6 commit fc0febe
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -467,10 +467,10 @@ function getConstructorName(obj, ctx, recurseTimes, protoProps) { | |||
| 467 | 467 | typeof descriptor.value === 'function' && | |
| 468 | 468 | descriptor.value.name !== '') { | |
| 469 | 469 | if (protoProps !== undefined && | |
| 470 | - !builtInObjects.has(descriptor.value.name)) { | ||
| 471 | - const isProto = firstProto !== undefined; | ||
| 470 | + (firstProto !== obj || | ||
| 471 | + !builtInObjects.has(descriptor.value.name))) { | ||
| 472 | 472 | addPrototypeProperties( | |
| 473 | - ctx, tmp, obj, recurseTimes, isProto, protoProps); | ||
| 473 | + ctx, tmp, firstProto || tmp, recurseTimes, protoProps); | ||
| 474 | 474 | } | |
| 475 | 475 | return descriptor.value.name; | |
| 476 | 476 | } | |
@@ -508,12 +508,12 @@ function getConstructorName(obj, ctx, recurseTimes, protoProps) { | |||
| 508 | 508 | // This function has the side effect of adding prototype properties to the | |
| 509 | 509 | // `output` argument (which is an array). This is intended to highlight user | |
| 510 | 510 | // defined prototype properties. | |
| 511 | - function addPrototypeProperties(ctx, main, obj, recurseTimes, isProto, output) { | ||
| 511 | + function addPrototypeProperties(ctx, main, obj, recurseTimes, output) { | ||
| 512 | 512 | let depth = 0; | |
| 513 | 513 | let keys; | |
| 514 | 514 | let keySet; | |
| 515 | 515 | do { | |
| 516 | - if (!isProto) { | ||
| 516 | + if (depth !== 0 || main === obj) { | ||
| 517 | 517 | obj = ObjectGetPrototypeOf(obj); | |
| 518 | 518 | // Stop as soon as a null prototype is encountered. | |
| 519 | 519 | if (obj === null) { | |
@@ -526,8 +526,6 @@ function addPrototypeProperties(ctx, main, obj, recurseTimes, isProto, output) { | |||
| 526 | 526 | builtInObjects.has(descriptor.value.name)) { | |
| 527 | 527 | return; | |
| 528 | 528 | } | |
| 529 | - } else { | ||
| 530 | - isProto = false; | ||
| 531 | 529 | } | |
| 532 | 530 | ||
| 533 | 531 | if (depth === 0) { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1687,7 +1687,8 @@ util.inspect(process); | |||
| 1687 | 1687 | ' 1,', | |
| 1688 | 1688 | ' 2,', | |
| 1689 | 1689 | ' [length]: 2', | |
| 1690 | - ' ]', | ||
| 1690 | + ' ],', | ||
| 1691 | + " [Symbol(Symbol.toStringTag)]: 'Set Iterator'", | ||
| 1691 | 1692 | ' } => [Map Iterator] {', | |
| 1692 | 1693 | ' Uint8Array(0) [', | |
| 1693 | 1694 | ' [BYTES_PER_ELEMENT]: 1,', | |
@@ -1699,7 +1700,8 @@ util.inspect(process); | |||
| 1699 | 1700 | ' foo: true', | |
| 1700 | 1701 | ' }', | |
| 1701 | 1702 | ' ],', | |
| 1702 | - ' [Circular]', | ||
| 1703 | + ' [Circular],', | ||
| 1704 | + " [Symbol(Symbol.toStringTag)]: 'Map Iterator'", | ||
| 1703 | 1705 | ' },', | |
| 1704 | 1706 | ' [size]: 2', | |
| 1705 | 1707 | '}' | |
@@ -1727,15 +1729,19 @@ util.inspect(process); | |||
| 1727 | 1729 | ' [byteOffset]: 0,', | |
| 1728 | 1730 | ' [buffer]: ArrayBuffer { byteLength: 0, foo: true }', | |
| 1729 | 1731 | ' ],', | |
| 1730 | - ' [Set Iterator] { [ 1, 2, [length]: 2 ] } => [Map Iterator] {', | ||
| 1732 | + ' [Set Iterator] {', | ||
| 1733 | + ' [ 1, 2, [length]: 2 ],', | ||
| 1734 | + " [Symbol(Symbol.toStringTag)]: 'Set Iterator'", | ||
| 1735 | + ' } => [Map Iterator] {', | ||
| 1731 | 1736 | ' Uint8Array(0) [', | |
| 1732 | 1737 | ' [BYTES_PER_ELEMENT]: 1,', | |
| 1733 | 1738 | ' [length]: 0,', | |
| 1734 | 1739 | ' [byteLength]: 0,', | |
| 1735 | 1740 | ' [byteOffset]: 0,', | |
| 1736 | 1741 | ' [buffer]: ArrayBuffer { byteLength: 0, foo: true }', | |
| 1737 | 1742 | ' ],', | |
| 1738 | - ' [Circular]', | ||
| 1743 | + ' [Circular],', | ||
| 1744 | + " [Symbol(Symbol.toStringTag)]: 'Map Iterator'", | ||
| 1739 | 1745 | ' },', | |
| 1740 | 1746 | ' [size]: 2', | |
| 1741 | 1747 | '}' | |
@@ -1767,7 +1773,9 @@ util.inspect(process); | |||
| 1767 | 1773 | ' [Set Iterator] {', | |
| 1768 | 1774 | ' [ 1,', | |
| 1769 | 1775 | ' 2,', | |
| 1770 | - ' [length]: 2 ] } => [Map Iterator] {', | ||
| 1776 | + ' [length]: 2 ],', | ||
| 1777 | + ' [Symbol(Symbol.toStringTag)]:', | ||
| 1778 | + " 'Set Iterator' } => [Map Iterator] {", | ||
| 1771 | 1779 | ' Uint8Array(0) [', | |
| 1772 | 1780 | ' [BYTES_PER_ELEMENT]: 1,', | |
| 1773 | 1781 | ' [length]: 0,', | |
@@ -1776,7 +1784,9 @@ util.inspect(process); | |||
| 1776 | 1784 | ' [buffer]: ArrayBuffer {', | |
| 1777 | 1785 | ' byteLength: 0,', | |
| 1778 | 1786 | ' foo: true } ],', | |
| 1779 | - ' [Circular] },', | ||
| 1787 | + ' [Circular],', | ||
| 1788 | + ' [Symbol(Symbol.toStringTag)]:', | ||
| 1789 | + " 'Map Iterator' },", | ||
| 1780 | 1790 | ' [size]: 2 }' | |
| 1781 | 1791 | ].join('\n'); | |
| 1782 | 1792 | ||
@@ -2678,4 +2688,11 @@ assert.strictEqual( | |||
| 2678 | 2688 | ' \x1B[2m[def]: \x1B[36m[Getter/Setter]\x1B[39m\x1B[22m\n' + | |
| 2679 | 2689 | '}' | |
| 2680 | 2690 | ); | |
| 2691 | + | ||
| 2692 | + const obj = Object.create({ abc: true, def: 5, toString() {} }); | ||
| 2693 | + assert.strictEqual( | ||
| 2694 | + inspect(obj, { showHidden: true, colors: true }), | ||
| 2695 | + '{ \x1B[2mabc: \x1B[33mtrue\x1B[39m\x1B[22m, ' + | ||
| 2696 | + '\x1B[2mdef: \x1B[33m5\x1B[39m\x1B[22m }' | ||
| 2697 | + ); | ||
| 2681 | 2698 | } | |
| Back | FazBrowse Home | New Git URL |
0 commit comments