mirror of
https://github.com/denoland/deno.git
synced 2024-11-26 16:09:27 -05:00
Avoid Uint8Array.prototype throwing type error in console.log (#1327)
This commit is contained in:
parent
585de35b1d
commit
8502cb0ccb
2 changed files with 7 additions and 3 deletions
|
@ -63,9 +63,12 @@ function createIterableString(
|
|||
ctx.add(value);
|
||||
|
||||
const entries: string[] = [];
|
||||
// In cases e.g. Uint8Array.prototype
|
||||
try {
|
||||
for (const el of value) {
|
||||
entries.push(config.entryHandler(el, ctx, level + 1, maxLevel));
|
||||
}
|
||||
} catch (e) {}
|
||||
ctx.delete(value);
|
||||
const iPrefix = `${config.displayName ? config.displayName + " " : ""}`;
|
||||
const iContent = entries.length === 0 ? "" : ` ${entries.join(", ")} `;
|
||||
|
|
|
@ -103,6 +103,7 @@ test(function consoleTestStringifyCircular() {
|
|||
"[AsyncGeneratorFunction: agf]"
|
||||
);
|
||||
assertEqual(stringify(new Uint8Array([1, 2, 3])), "Uint8Array [ 1, 2, 3 ]");
|
||||
assertEqual(stringify(Uint8Array.prototype), "TypedArray []");
|
||||
assertEqual(
|
||||
stringify({ a: { b: { c: { d: new Set([1]) } } } }),
|
||||
"{ a: { b: { c: { d: [Set] } } } }"
|
||||
|
|
Loading…
Reference in a new issue