Package Exports
- rfdc
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (rfdc) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
rfdc
Really Fast Deep Clone
Usage
const clone = require('rfdc')()
clone({a: 1, b: {c: 2}}) // => {a: 1, b: {c: 2}}
API
require('rfdc')(opts = { proto: false }) => clone(obj) => obj2
proto
option
It's faster to allow enumerable properties on the prototype to be copied into the cloned object (not onto it's prototype, directly onto the object).
To explain by way of code:
require('rfdc')({ proto: false })(Object.create({a: 1})) // => {}
require('rfdc')({ proto: true })(Object.create({a: 1})) // => {a: 1}
If this behavior is acceptable, set
proto
to true
for an additional 15% performance boost
(see benchmarks).
Benchmarks
npm run bench
benchDeepCopy*100: 624.535ms
benchLodashCloneDeep*100: 1740.670ms
benchRfdc*100: 547.896ms
benchRfdcProto*100: 467.896ms
Tests
npm test
52 passing (287.896ms)
Coverage
npm run cov
----------|----------|----------|----------|----------|-------------------|
File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s |
----------|----------|----------|----------|----------|-------------------|
All files | 100 | 100 | 100 | 100 | |
index.js | 100 | 100 | 100 | 100 | |
----------|----------|----------|----------|----------|-------------------|
License
MIT