| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent ffbf790 commit a699808
6 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -117,6 +117,9 @@ const setSizeGetter = uncurryThis( | |||
| 117 | 117 | ObjectGetOwnPropertyDescriptor(SetPrototype, 'size').get); | |
| 118 | 118 | const mapSizeGetter = uncurryThis( | |
| 119 | 119 | ObjectGetOwnPropertyDescriptor(MapPrototype, 'size').get); | |
| 120 | + const typedArraySizeGetter = uncurryThis( | ||
| 121 | + ObjectGetOwnPropertyDescriptor( | ||
| 122 | + ObjectGetPrototypeOf(Uint8Array.prototype), 'length').get); | ||
| 120 | 123 | ||
| 121 | 124 | let hexSlice; | |
| 122 | 125 | ||
@@ -562,18 +565,18 @@ function addPrototypeProperties(ctx, main, obj, recurseTimes, isProto, output) { | |||
| 562 | 565 | } while (++depth !== 3); | |
| 563 | 566 | } | |
| 564 | 567 | ||
| 565 | - function getPrefix(constructor, tag, fallback) { | ||
| 568 | + function getPrefix(constructor, tag, fallback, size = '') { | ||
| 566 | 569 | if (constructor === null) { | |
| 567 | 570 | if (tag !== '') { | |
| 568 | - return `[${fallback}: null prototype] [${tag}] `; | ||
| 571 | + return `[${fallback}${size}: null prototype] [${tag}] `; | ||
| 569 | 572 | } | |
| 570 | - return `[${fallback}: null prototype] `; | ||
| 573 | + return `[${fallback}${size}: null prototype] `; | ||
| 571 | 574 | } | |
| 572 | 575 | ||
| 573 | 576 | if (tag !== '' && constructor !== tag) { | |
| 574 | - return `${constructor} [${tag}] `; | ||
| 577 | + return `${constructor}${size} [${tag}] `; | ||
| 575 | 578 | } | |
| 576 | - return `${constructor} `; | ||
| 579 | + return `${constructor}${size} `; | ||
| 577 | 580 | } | |
| 578 | 581 | ||
| 579 | 582 | // Look up the keys of the object. | |
@@ -758,58 +761,48 @@ function formatRaw(ctx, value, recurseTimes, typedArray) { | |||
| 758 | 761 | if (value[SymbolIterator] || constructor === null) { | |
| 759 | 762 | noIterator = false; | |
| 760 | 763 | if (ArrayIsArray(value)) { | |
| 761 | - keys = getOwnNonIndexProperties(value, filter); | ||
| 762 | 764 | // Only set the constructor for non ordinary ("Array [...]") arrays. | |
| 763 | - const prefix = getPrefix(constructor, tag, 'Array'); | ||
| 764 | - braces = [`${prefix === 'Array ' ? '' : prefix}[`, ']']; | ||
| 765 | + const prefix = (constructor !== 'Array' || tag !== '') ? | ||
| 766 | + getPrefix(constructor, tag, 'Array', `(${value.length})`) : | ||
| 767 | + ''; | ||
| 768 | + keys = getOwnNonIndexProperties(value, filter); | ||
| 769 | + braces = [`${prefix}[`, ']']; | ||
| 765 | 770 | if (value.length === 0 && keys.length === 0 && protoProps === undefined) | |
| 766 | 771 | return `${braces[0]}]`; | |
| 767 | 772 | extrasType = kArrayExtrasType; | |
| 768 | 773 | formatter = formatArray; | |
| 769 | 774 | } else if (isSet(value)) { | |
| 770 | 775 | const size = setSizeGetter(value); | |
| 776 | + const prefix = getPrefix(constructor, tag, 'Set', `(${size})`); | ||
| 771 | 777 | keys = getKeys(value, ctx.showHidden); | |
| 772 | - let prefix = ''; | ||
| 773 | - if (constructor !== null) { | ||
| 774 | - if (constructor === tag) | ||
| 775 | - tag = ''; | ||
| 776 | - prefix = getPrefix(`${constructor}(${size})`, tag, ''); | ||
| 777 | - formatter = formatSet.bind(null, value, size); | ||
| 778 | - } else { | ||
| 779 | - prefix = getPrefix(constructor, tag, `Set(${size})`); | ||
| 780 | - formatter = formatSet.bind(null, SetPrototypeValues(value), size); | ||
| 781 | - } | ||
| 778 | + formatter = constructor !== null ? | ||
| 779 | + formatSet.bind(null, value) : | ||
| 780 | + formatSet.bind(null, SetPrototypeValues(value)); | ||
| 782 | 781 | if (size === 0 && keys.length === 0 && protoProps === undefined) | |
| 783 | 782 | return `${prefix}{}`; | |
| 784 | 783 | braces = [`${prefix}{`, '}']; | |
| 785 | 784 | } else if (isMap(value)) { | |
| 786 | 785 | const size = mapSizeGetter(value); | |
| 786 | + const prefix = getPrefix(constructor, tag, 'Map', `(${size})`); | ||
| 787 | 787 | keys = getKeys(value, ctx.showHidden); | |
| 788 | - let prefix = ''; | ||
| 789 | - if (constructor !== null) { | ||
| 790 | - if (constructor === tag) | ||
| 791 | - tag = ''; | ||
| 792 | - prefix = getPrefix(`${constructor}(${size})`, tag, ''); | ||
| 793 | - formatter = formatMap.bind(null, value, size); | ||
| 794 | - } else { | ||
| 795 | - prefix = getPrefix(constructor, tag, `Map(${size})`); | ||
| 796 | - formatter = formatMap.bind(null, MapPrototypeEntries(value), size); | ||
| 797 | - } | ||
| 788 | + formatter = constructor !== null ? | ||
| 789 | + formatMap.bind(null, value) : | ||
| 790 | + formatMap.bind(null, MapPrototypeEntries(value)); | ||
| 798 | 791 | if (size === 0 && keys.length === 0 && protoProps === undefined) | |
| 799 | 792 | return `${prefix}{}`; | |
| 800 | 793 | braces = [`${prefix}{`, '}']; | |
| 801 | 794 | } else if (isTypedArray(value)) { | |
| 802 | 795 | keys = getOwnNonIndexProperties(value, filter); | |
| 803 | 796 | let bound = value; | |
| 804 | - let prefix = ''; | ||
| 797 | + let fallback = ''; | ||
| 805 | 798 | if (constructor === null) { | |
| 806 | 799 | const constr = findTypedConstructor(value); | |
| 807 | - prefix = getPrefix(constructor, tag, constr.name); | ||
| 800 | + fallback = constr.name; | ||
| 808 | 801 | // Reconstruct the array information. | |
| 809 | 802 | bound = new constr(value); | |
| 810 | - } else { | ||
| 811 | - prefix = getPrefix(constructor, tag); | ||
| 812 | 803 | } | |
| 804 | + const size = typedArraySizeGetter(value); | ||
| 805 | + const prefix = getPrefix(constructor, tag, fallback, `(${size})`); | ||
| 813 | 806 | braces = [`${prefix}[`, ']']; | |
| 814 | 807 | if (value.length === 0 && keys.length === 0 && !ctx.showHidden) | |
| 815 | 808 | return `${braces[0]}]`; | |
@@ -1425,7 +1418,7 @@ function formatTypedArray(value, ctx, ignored, recurseTimes) { | |||
| 1425 | 1418 | return output; | |
| 1426 | 1419 | } | |
| 1427 | 1420 | ||
| 1428 | - function formatSet(value, size, ctx, ignored, recurseTimes) { | ||
| 1421 | + function formatSet(value, ctx, ignored, recurseTimes) { | ||
| 1429 | 1422 | const output = []; | |
| 1430 | 1423 | ctx.indentationLvl += 2; | |
| 1431 | 1424 | for (const v of value) { | |
@@ -1435,7 +1428,7 @@ function formatSet(value, size, ctx, ignored, recurseTimes) { | |||
| 1435 | 1428 | return output; | |
| 1436 | 1429 | } | |
| 1437 | 1430 | ||
| 1438 | - function formatMap(value, size, ctx, ignored, recurseTimes) { | ||
| 1431 | + function formatMap(value, ctx, ignored, recurseTimes) { | ||
| 1439 | 1432 | const output = []; | |
| 1440 | 1433 | ctx.indentationLvl += 2; | |
| 1441 | 1434 | for (const [k, v] of value) { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -51,8 +51,8 @@ assert.throws( | |||
| 51 | 51 | { | |
| 52 | 52 | code: 'ERR_ASSERTION', | |
| 53 | 53 | message: `${defaultMsgStartFull} ... Lines skipped\n\n` + | |
| 54 | - '+ Uint8Array [\n' + | ||
| 55 | - '- Buffer [Uint8Array] [\n 120,\n...\n 122,\n 10\n ]' | ||
| 54 | + '+ Uint8Array(4) [\n' + | ||
| 55 | + '- Buffer(4) [Uint8Array] [\n 120,\n...\n 122,\n 10\n ]' | ||
| 56 | 56 | } | |
| 57 | 57 | ); | |
| 58 | 58 | assert.deepEqual(arr, buf); | |
@@ -66,7 +66,7 @@ assert.deepEqual(arr, buf); | |||
| 66 | 66 | { | |
| 67 | 67 | code: 'ERR_ASSERTION', | |
| 68 | 68 | message: `${defaultMsgStartFull}\n\n` + | |
| 69 | - ' Buffer [Uint8Array] [\n' + | ||
| 69 | + ' Buffer(4) [Uint8Array] [\n' + | ||
| 70 | 70 | ' 120,\n' + | |
| 71 | 71 | ' 121,\n' + | |
| 72 | 72 | ' 122,\n' + | |
@@ -86,7 +86,7 @@ assert.deepEqual(arr, buf); | |||
| 86 | 86 | { | |
| 87 | 87 | code: 'ERR_ASSERTION', | |
| 88 | 88 | message: `${defaultMsgStartFull}\n\n` + | |
| 89 | - ' Uint8Array [\n' + | ||
| 89 | + ' Uint8Array(4) [\n' + | ||
| 90 | 90 | ' 120,\n' + | |
| 91 | 91 | ' 121,\n' + | |
| 92 | 92 | ' 122,\n' + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -58,7 +58,7 @@ b.inspect = undefined; | |||
| 58 | 58 | b.prop = new Uint8Array(0); | |
| 59 | 59 | assert.strictEqual( | |
| 60 | 60 | util.inspect(b), | |
| 61 | - '<Buffer 31 32, inspect: undefined, prop: Uint8Array []>' | ||
| 61 | + '<Buffer 31 32, inspect: undefined, prop: Uint8Array(0) []>' | ||
| 62 | 62 | ); | |
| 63 | 63 | ||
| 64 | 64 | b = Buffer.alloc(0); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -15,7 +15,7 @@ assert.throws( | |||
| 15 | 15 | { | |
| 16 | 16 | code: 'ERR_INVALID_ARG_VALUE', | |
| 17 | 17 | message: 'The argument \'buffer\' is empty and cannot be written. ' + | |
| 18 | - 'Received Uint8Array []' | ||
| 18 | + 'Received Uint8Array(0) []' | ||
| 19 | 19 | } | |
| 20 | 20 | ); | |
| 21 | 21 | ||
@@ -24,7 +24,7 @@ assert.throws( | |||
| 24 | 24 | { | |
| 25 | 25 | code: 'ERR_INVALID_ARG_VALUE', | |
| 26 | 26 | message: 'The argument \'buffer\' is empty and cannot be written. ' + | |
| 27 | - 'Received Uint8Array []' | ||
| 27 | + 'Received Uint8Array(0) []' | ||
| 28 | 28 | } | |
| 29 | 29 | ); | |
| 30 | 30 | ||
@@ -35,7 +35,7 @@ assert.throws( | |||
| 35 | 35 | { | |
| 36 | 36 | code: 'ERR_INVALID_ARG_VALUE', | |
| 37 | 37 | message: 'The argument \'buffer\' is empty and cannot be written. ' + | |
| 38 | - 'Received Uint8Array []' | ||
| 38 | + 'Received Uint8Array(0) []' | ||
| 39 | 39 | } | |
| 40 | 40 | ); | |
| 41 | 41 | })(); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -158,7 +158,7 @@ assert.strictEqual(util.format('%s', () => 5), '() => 5'); | |||
| 158 | 158 | class Foobar extends Array { aaa = true; } | |
| 159 | 159 | assert.strictEqual( | |
| 160 | 160 | util.format('%s', new Foobar(5)), | |
| 161 | - 'Foobar [ <5 empty items>, aaa: true ]' | ||
| 161 | + 'Foobar(5) [ <5 empty items>, aaa: true ]' | ||
| 162 | 162 | ); | |
| 163 | 163 | ||
| 164 | 164 | // Subclassing: | |
| Back | FazBrowse Home | New Git URL |
0 commit comments