1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2025-01-18 11:53:59 -05:00

chore(extensions/console): avoid re-checking iterable type (#11349)

This commit is contained in:
Divy Srivastava 2021-07-26 17:16:48 +05:30 committed by GitHub
parent 72ac9c3ae0
commit df26a3563e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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;