tupleson
tupleson copied to clipboard
feat: sync back-references
DISCLAIMERS:
- this PR is a POC, code isn't very clean (the reference handling is done directly in the walkers, and not in its own neat plugin).
- this PR was just a toy idea initially, there is absolutely no issue with simply throwing the code away
Add support for back-references:
- support preserving identity of objects
const a = {} const data = { foo: a, bar: a, } const res = tson.parse(tson.stringify(data)) res.foo === res.bar // true - support circular references
const data = {} data.foo = data const res = tson.parse(tson.stringify(data)) data === data.foo // true
This PR also includes
- changes in benchmark
- use
Intl.NumberFormatto format results - use
process.memoryUsageto also log memory information (though I'm not sure how to interpret it, nor whether it's actually useful...)
- use
This PR does not include
- changes to async methods (serialize / deserialize) to enable back-references in these cases too
Codecov Report
Attention: 20 lines in your changes are missing coverage. Please review.
| Files | Coverage Ξ | |
|---|---|---|
| src/sync/serialize.ts | 100.00% <100.00%> (ΓΈ) |
|
| src/sync/deserialize.ts | 86.11% <78.26%> (-13.89%) |
:arrow_down: |
... and 5 files with indirect coverage changes
:loudspeaker: Thoughts on this report? Let us know!.