refactor(linter/plugins): introduce methods for deep cloning JSON values#16962
Conversation
How to use the Graphite Merge QueueAdd either label to this PR to merge it via the merge queue:
You must have a Graphite account in order to use the merge queue. Sign up using this link. An organization admin has enabled the Graphite Merge Queue in this repository. Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue. This stack of pull requests is managed by Graphite. Learn more about stacking. |
There was a problem hiding this comment.
Pull request overview
This PR introduces deep cloning functionality for JSON values, complementing the existing deep freeze utilities. The implementation adds three new functions that handle recursive cloning of JSON objects, arrays, and primitive values.
Key changes:
- Added
deepCloneJsonValueas the main entry point for cloning any JSON value - Implemented
deepCloneJsonObjectanddeepCloneJsonArrayfor recursive cloning of complex types
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
dfb2fbc to
2763b8f
Compare
1abbb33 to
1351d60
Compare
1a6536f to
d827a4a
Compare
2763b8f to
220c326
Compare
220c326 to
b27b3c1
Compare
d827a4a to
da509be
Compare
b27b3c1 to
b1a8ac2
Compare
|
No idea of perf, but was https://developer.mozilla.org/en-US/docs/Web/API/Window/structuredClone considered? |
|
Thanks for your comment. I hadn't thought of that. I don't know for sure either, but I imagine the manual implementation is probably faster, as JSON objects are much more constrained (simple) than what you can pass to This isn't on a hot path, so not so important for perf. So I hope you'll forgive me if I just go with it as is. |
Merge activity
|
b1a8ac2 to
4c4de62
Compare
|
strucutredClone is really slow. 😓 Not sure of the perf diff vs this implementation |
Follow-on after #16962. Small optimization to `deepCloneJsonObject`. Iterate through keys of `cloned` instead of `obj`. Benchmark shows this is marginally faster (0.3%): https://benchmarklab.azurewebsites.net/Benchmarks/ShowResult/622556
…ues (oxc-project#16962) Add methods for deep cloning JSON values, objects, and arrays. These are used in the next PR (oxc-project#16930).
Follow-on after oxc-project#16962. Small optimization to `deepCloneJsonObject`. Iterate through keys of `cloned` instead of `obj`. Benchmark shows this is marginally faster (0.3%): https://benchmarklab.azurewebsites.net/Benchmarks/ShowResult/622556


Add methods for deep cloning JSON values, objects, and arrays. These are used in the next PR (#16930).