deep-cloner
v1.0.1
Published
Deep cloning of arrays and objects.
Downloads
1
Readme
deep-cloner
This package offers deep cloning of objects, arrays, numbers, strings, maps, sets and dates in JavaScript.
Installation
$ npm install deep-cloner
Example
const clone = require('deep-cloner');
const x = { foo: { bar: 'bazinga' } }; // initial value of x
const y = clone(x); // clone x -> y
x.foo.bar = 'foo'; // update x
console.log(x);
console.log(y);
This will print:
{ foo: { bar: 'foo' } }
{ foo: { bar: 'bazinga' } }
API
clone(value)
value
: The value that you want to clone.