0
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2025-03-03 17:34:47 -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 = []; const entries = [];
let iter; let iter;
// TODO(littledivy): Avoid re-checking iterable type switch (options.typeName) {
if (ArrayIsArray(value) || isTypedArray(value)) { case "Map":
iter = ArrayPrototypeEntries(value); iter = MapPrototypeEntries(value);
} else if (value instanceof Set) { break;
iter = SetPrototypeEntries(value); case "Set":
} else if (value instanceof Map) { iter = SetPrototypeEntries(value);
iter = MapPrototypeEntries(value); break;
} else { case "Array":
throw new TypeError("Unreachable"); iter = ArrayPrototypeEntries(value);
break;
default:
if (isTypedArray(value)) {
iter = ArrayPrototypeEntries(value);
} else {
throw new TypeError("unreachable");
}
} }
let entriesLength = 0; let entriesLength = 0;