mirror of
https://github.com/denoland/deno.git
synced 2024-10-29 08:58:01 -04:00
fix sparse array inspection (#16204)
fix https://github.com/denoland/deno/issues/16202
This commit is contained in:
parent
1ab3691b09
commit
70ad6717df
2 changed files with 15 additions and 3 deletions
|
@ -770,6 +770,16 @@ Deno.test(function consoleTestStringifyIterable() {
|
|||
`[ <1 empty item> ]`,
|
||||
);
|
||||
|
||||
assertEquals(
|
||||
stringify([, , 1]),
|
||||
`[ <2 empty items>, 1 ]`,
|
||||
);
|
||||
|
||||
assertEquals(
|
||||
stringify([1, , , 1]),
|
||||
`[ 1, <2 empty items>, 1 ]`,
|
||||
);
|
||||
|
||||
const withEmptyElAndMoreItems = Array(500);
|
||||
withEmptyElAndMoreItems.fill(0, 50, 80);
|
||||
withEmptyElAndMoreItems.fill(2, 100, 120);
|
||||
|
|
|
@ -417,6 +417,7 @@
|
|||
}
|
||||
}
|
||||
|
||||
let entriesLengthWithoutEmptyItems = entriesLength;
|
||||
if (options.typeName === "Array") {
|
||||
for (
|
||||
let i = 0, j = 0;
|
||||
|
@ -433,7 +434,7 @@
|
|||
|
||||
if (skipTo) {
|
||||
// subtract skipped (empty) items
|
||||
entriesLength -= skipTo - i;
|
||||
entriesLengthWithoutEmptyItems -= skipTo - i;
|
||||
i = skipTo;
|
||||
}
|
||||
}
|
||||
|
@ -478,8 +479,9 @@
|
|||
ArrayPrototypeSort(entries);
|
||||
}
|
||||
|
||||
if (entriesLength > inspectOptions.iterableLimit) {
|
||||
const nmore = entriesLength - inspectOptions.iterableLimit;
|
||||
if (entriesLengthWithoutEmptyItems > inspectOptions.iterableLimit) {
|
||||
const nmore = entriesLengthWithoutEmptyItems -
|
||||
inspectOptions.iterableLimit;
|
||||
ArrayPrototypePush(entries, `... ${nmore} more items`);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue