1.0.1 • Published 2 years ago

deep-cloner v1.0.1

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

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.