Open pabx06 opened 7 months ago
the spread operator won't work here since it only clones the top level keys
maybe the code can be refactored to avoid cloning altogether. like here it shouldn't make a difference if it uses the original node or a copy: https://github.com/relative/synchrony/blob/721cf5dcd410f9c603484f21ceaae1f2a07deaff/src/transformers/simplify.ts#L225-L231 the only place where it might be necessary is related to control flow functions
Pretty sure this one is better
-native deep clone: structuredClone: https://developer.mozilla.org/en-US/docs/Web/API/structuredClone
based on my tests structuredClone is a fair bit slower than json parse/stringify, but as long as it fixes the issue it shouldn't matter too much
but there are some significantly faster alternatives that could also be used: https://github.com/lukeed/klona/blob/master/src/json.js (benchmark), can even improve the perf by another 25% by not checking for __proto__
fix for #134
JSON.parse(JSON.stringify(item))
have trouble on large object