* Helper to decycle json objects
()
| 297 | * Helper to decycle json objects |
| 298 | */ |
| 299 | function memoBuilder(): MemoFunc { |
| 300 | const inner = new WeakSet<object>(); |
| 301 | function memoize(obj: object): boolean { |
| 302 | if (inner.has(obj)) { |
| 303 | return true; |
| 304 | } |
| 305 | inner.add(obj); |
| 306 | return false; |
| 307 | } |
| 308 | |
| 309 | function unmemoize(obj: object): void { |
| 310 | inner.delete(obj); |
| 311 | } |
| 312 | return [memoize, unmemoize]; |
| 313 | } |