@arnab333/deep-copy
v0.8.0
Published
> Recursively (deep) copy JavaScript native types, like Object, Array, RegExp, Date as well as primitives.
Downloads
9
Maintainers
Readme
@arnab333/deep-copy
Recursively (deep) copy JavaScript native types, like Object, Array, RegExp, Date as well as primitives.
Install
Install with npm:
$ npm install @arnab333/deep-copy
Usage
const deepCopy = require('@arnab333/deep-copy');
// OR
const { deepCopy } = require('@arnab333/deep-copy');
// OR
import { deepCopy } from '@arnab333/deep-copy';
// OR
import deepCopy from '@arnab333/deep-copy';
let obj = { a: 'b' };
let arr = [obj];
let copy = deepCopy(arr);
obj.c = 'd';
console.log(copy);
//=> [{ a: 'b' }]
console.log(arr);
//=> [{ a: 'b', c: 'd' }]