File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -179,18 +179,18 @@ export function equals(one: any, other: any): boolean {
179179}
180180
181181/**
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
184184 * "Uncaught TypeError: Converting circular structure to JSON"
185185 */
186186export function safeStringify ( obj : any ) : string {
187- const seen : any [ ] = [ ] ;
187+ const seen = new Set < any > ( ) ;
188188 return JSON . stringify ( obj , ( key , value ) => {
189189 if ( isObject ( value ) || Array . isArray ( value ) ) {
190- if ( seen . indexOf ( value ) !== - 1 ) {
190+ if ( seen . has ( value ) ) {
191191 return '[Circular]' ;
192192 } else {
193- seen . push ( value ) ;
193+ seen . add ( value ) ;
194194 }
195195 }
196196 return value ;
You can’t perform that action at this time.
0 commit comments