js-clone-deep

1.0.0 • Public • Published

js-clone-deep

JavaScript utility method for deep cloning Object and Array.

How to use

Get the npm module from here

const clone = require('js-clone-deep');
 
// Source object
const source = {
  object: { nested: { deepNesting: { key: 1 } }  },
  array: [1 , 2, 4],
};
 
// Clone the object
const copy = clone(source);
 
console.log(source.object === copy.object);
// false
 
console.log(source.array === copy.array);
// false
 

Developer warning

This method currently supports deep cloning of Object ({}) and Array ([]) only. Data structures such Set, WeakSets, Maps, WeakMaps, Streams, etc will not be cloned.

Use this module considering the above limitation.

Readme

Keywords

Package Sidebar

Install

npm i js-clone-deep

Weekly Downloads

2

Version

1.0.0

License

MIT

Unpacked Size

3.35 kB

Total Files

3

Last publish

Collaborators

  • theekshanawj