Skip to content

Commit 07158d0

Browse files
committed
Serialization improvements
1 parent 46c753a commit 07158d0

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

website/src/js/playground.js

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,10 @@ function init() {
9999
visited.add(value);
100100
}
101101

102+
if (value instanceof Promise) {
103+
return 'Promise { <pending> }';
104+
}
105+
102106
if (value instanceof Set) {
103107
const arr = Array.from(value, v => serializeLog(v, visited));
104108
return `Set {${ arr.join(', ') }}`;
@@ -124,6 +128,10 @@ function init() {
124128
return `[${ arr.join(', ') }]`;
125129
}
126130

131+
if (value instanceof Error) {
132+
return `${ value.name || 'Error' }: ${ value.message }`;
133+
}
134+
127135
if (value instanceof Date) {
128136
return `Date "${ value.toISOString() }"`;
129137
}
@@ -133,7 +141,10 @@ function init() {
133141
}
134142

135143
if (typeof value === 'object') {
136-
const keys = Object.keys(value);
144+
const keys = Array.from(new Set([
145+
...Object.getOwnPropertyNames(value),
146+
...Object.getOwnPropertySymbols(value)
147+
]));
137148
if (!keys.length) return '{}';
138149
const props = keys.map(k => `${ JSON.stringify(k) }: ${ serializeLog(value[k], visited) }`);
139150
return `{${ props.join(', ') }}`;

0 commit comments

Comments
 (0)