Skip to content
This repository has been archived by the owner on Jul 5, 2024. It is now read-only.

feat: sync back-references #56

Draft
wants to merge 11 commits into
base: main
Choose a base branch
from
Draft

feat: sync back-references #56

wants to merge 11 commits into from

Conversation

Sheraff
Copy link
Contributor

@Sheraff Sheraff commented Oct 8, 2023

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.NumberFormat to format results
    • use process.memoryUsage to also log memory information (though I'm not sure how to interpret it, nor whether it's actually useful...)

This PR does not include

  • changes to async methods (serialize / deserialize) to enable back-references in these cases too

@codecov
Copy link

codecov bot commented Oct 8, 2023

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%) ⬇️

... and 5 files with indirect coverage changes

📢 Thoughts on this report? Let us know!.

@Sheraff Sheraff self-assigned this Oct 8, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants