@logicamente.info/clone
v1.0.1
Published
Quickly clones a object structure
Downloads
1
Readme
@logicamente.info/clone
Quickly clones a object structure
Installation
npm install --save @logicamente.info/clone
# or
yarn add @logicamente.info/clone
Usage
const clone = require('@logicamente.info/clone');
const a = { foo: { bar: 'foo' } };
const b = clone(a);
b.foo.bar = 'bar';
console.log(a);
console.log(b);
Will produce:
{ foo: { bar: 'foo' } }
{ foo: { bar: 'bar' } }
Why that clone dep?
Our algorithm is mastered to clone common objects, not containing any classes instances. That's why we rely on the original mighty https://github.com/pvorb/clone module.
For plain objects, this module is the fastest in the wild as you can witness in our tests results (Video proof). But considering class instances copying, we realized that clone is the fastest code alive.