Skip to content

Commit

Permalink
Avoid Uint8Array.prototype throwing type error in console.log (denola…
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinkassimo authored and ry committed Dec 12, 2018
1 parent 585de35 commit 8502cb0
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
9 changes: 6 additions & 3 deletions js/console.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,12 @@ function createIterableString(
ctx.add(value);

const entries: string[] = [];
for (const el of value) {
entries.push(config.entryHandler(el, ctx, level + 1, maxLevel));
}
// 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(", ")} `;
Expand Down
1 change: 1 addition & 0 deletions js/console_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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] } } } }"
Expand Down

0 comments on commit 8502cb0

Please sign in to comment.