mirror of
https://github.com/denoland/deno.git
synced 2025-01-18 03:44:05 -05:00
chore(extensions/console): avoid re-checking iterable type (#11349)
This commit is contained in:
parent
72ac9c3ae0
commit
df26a3563e
1 changed files with 16 additions and 9 deletions
|
@ -351,15 +351,22 @@
|
|||
const entries = [];
|
||||
let iter;
|
||||
|
||||
// TODO(littledivy): Avoid re-checking iterable type
|
||||
if (ArrayIsArray(value) || isTypedArray(value)) {
|
||||
iter = ArrayPrototypeEntries(value);
|
||||
} else if (value instanceof Set) {
|
||||
iter = SetPrototypeEntries(value);
|
||||
} else if (value instanceof Map) {
|
||||
switch (options.typeName) {
|
||||
case "Map":
|
||||
iter = MapPrototypeEntries(value);
|
||||
break;
|
||||
case "Set":
|
||||
iter = SetPrototypeEntries(value);
|
||||
break;
|
||||
case "Array":
|
||||
iter = ArrayPrototypeEntries(value);
|
||||
break;
|
||||
default:
|
||||
if (isTypedArray(value)) {
|
||||
iter = ArrayPrototypeEntries(value);
|
||||
} else {
|
||||
throw new TypeError("Unreachable");
|
||||
throw new TypeError("unreachable");
|
||||
}
|
||||
}
|
||||
|
||||
let entriesLength = 0;
|
||||
|
|
Loading…
Add table
Reference in a new issue