Skip to content

docs(clone): stronger usage example + table of contents#40

Merged
ob-aion merged 1 commit into
mainfrom
docs/usage-example-toc
May 15, 2026
Merged

docs(clone): stronger usage example + table of contents#40
ob-aion merged 1 commit into
mainfrom
docs/usage-example-toc

Conversation

@ob-aion
Copy link
Copy Markdown
Collaborator

@ob-aion ob-aion commented May 15, 2026

Summary

The Usage section only showed reads, which doesn't convey what a structural clone actually preserves. Replace it with a runnable example that demonstrates mutation isolation through a side-effecting method, then a direct, verified divergence from lodash.cloneDeep. Add a table of contents.

Changes

  • Usage rewrite — three blocks: (1) mutate the copy via a class method, source untouched, prototype + Map survive; (2) lodash.cloneDeep flattens a getter to its clone-time value (stale total) and silently drops a non-enumerable key, where clone keeps both live; (3) freeze locking the graph recursively.
  • TOC## Contents linking the top-level sections.

Accuracy

Every value in the example was verified empirically against the installed lodash.clonedeep and the built clone:

Check clone lodash.cloneDeep
getter stays live after array push 115 15 (frozen at clone time)
total descriptor has get true false
non-enumerable secret 'k-1' undefined
instanceof / Map preserved also preserved (not claimed otherwise)

lodash keeps prototypes and native types; the example does not claim otherwise. It targets only the accessor and non-enumerable cases where the two genuinely diverge.

Test plan

  • All example outputs reproduced via a scratch script against dist/ + lodash.clonedeep (script not committed)
  • Markdown anchors verified for the TOC
  • CI green on this PR

Copy link
Copy Markdown
Collaborator Author

@ob-aion ob-aion left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK

@ob-aion ob-aion force-pushed the docs/usage-example-toc branch from 1f9b64f to 0e4108c Compare May 15, 2026 10:39
@ob-aion ob-aion merged commit 4ff6875 into main May 15, 2026
5 checks passed
@ob-aion ob-aion deleted the docs/usage-example-toc branch May 15, 2026 10:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant