Releases: coroboros/clone
Releases · coroboros/clone
1.0.3
1.0.2
1.0.1
1.0.0
Initial release of @coroboros/clone.
Features
clone<T>(thing, options?)— deep clone preserving the prototype chain, property descriptors, boxed primitives, native types (Map,Set,Date,RegExp,Errorsubclasses,TypedArray,DataView,ArrayBuffer,Buffer), and null-prototype objects. Cycle-safe via aWeakMapvisited cache.freeze<T>(thing)— recursive deep freeze with aWeakSetcycle guard. SkipsArrayBufferViewinstances (TypedArray,DataView,Buffer) sinceObject.freezethrows on them.- Three granular opt-out flags on
CloneOptions:cycles,preservePrototype,copyDescriptors. All defaulttrue. Composing all threefalsegives a fast plain-JSON path competitive withrfdc. CloneErrorwithcode: 'UNSUPPORTED_TYPE'andError.causesupport.clonethrows it on functions,Promise,Intl.*,WeakMap,WeakSet, and constructor functions.- Browser-safe — the Buffer branch reads
globalThis.Bufferat module init, so the package works in non-Node bundles.
Documentation
- README ships with a full API reference, the comparison table vs
structuredClone/lodash.cloneDeep/rfdc/fast-copy, and the rationale for the prototype + descriptor preservation contract. bench/baseline.mddocuments the 1.0.0 numbers across five fixture buckets (flat-10, nested-100, large-1000, with-cycles, class-instances) on Apple M1 / Node 22.22.2.
Configuration
- TypeScript strict, ES modules + CJS dual build via
tsdowntargeting Node 22 LTS. Zero runtime dependencies. mitatabenchmark suite viapnpm bench.fast-checkproperty-test suite alongside the unit tests..github/workflows/ci.ymlcalls thecoroboros/ci@v0reusable workflow with OIDC Trusted Publisher andnpm provenance.