0.8.0 • Published 3 years ago

@arnab333/deep-copy v0.8.0

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

@arnab333/deep-copy NPM version

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' }]