File tree 1 file changed +5
-5
lines changed
1 file changed +5
-5
lines changed Original file line number Diff line number Diff line change @@ -179,18 +179,18 @@ export function equals(one: any, other: any): boolean {
179
179
}
180
180
181
181
/**
182
- * Calls JSON.Stringify with a replacer to break apart any circular references.
183
- * This prevents JSON.stringify from throwing the exception
182
+ * Calls ` JSON.Stringify` with a replacer to break apart any circular references.
183
+ * This prevents ` JSON` .stringify` from throwing the exception
184
184
* "Uncaught TypeError: Converting circular structure to JSON"
185
185
*/
186
186
export function safeStringify ( obj : any ) : string {
187
- const seen : any [ ] = [ ] ;
187
+ const seen = new Set < any > ( ) ;
188
188
return JSON . stringify ( obj , ( key , value ) => {
189
189
if ( isObject ( value ) || Array . isArray ( value ) ) {
190
- if ( seen . indexOf ( value ) !== - 1 ) {
190
+ if ( seen . has ( value ) ) {
191
191
return '[Circular]' ;
192
192
} else {
193
- seen . push ( value ) ;
193
+ seen . add ( value ) ;
194
194
}
195
195
}
196
196
return value ;
You can’t perform that action at this time.
0 commit comments