githubEdit

clone-deep

Recursively (deep) clone JavaScript native types, like Object, Array, RegExp, Date as well as primitives.

The instanceClone function is invoked to clone objects that are not "plain" objects (as defined byisPlainObject) if it is provided. If instanceClone is not specified, it will not attempt to clone non-plain objects, and will copy the object reference.

Install

Install with npmarrow-up-right

$ npm i clone-deep --save

Usage

var cloneDeep = require('clone-deep');

var obj = {a: 'b'};
var arr = [obj];

var copy = cloneDeep(arr);
obj.c = 'd';

console.log(copy);
//=> [{a: 'b'}]

console.log(arr);
//=> [{a: 'b', c: 'd'}]

Other object utils

Running tests

Install dev dependencies:

Contributing

Pull requests and stars are always welcome. For bugs and feature requests, please create an issuearrow-up-right.

Author

Jon Schlinkert

Based on mout'sarrow-up-right implementation of deepClone.

License

Copyright © 2014-2015 Jon Schlinkertarrow-up-right Released under the MIT license.


This file was generated by verbarrow-up-right on December 23, 2015.

Last updated

Was this helpful?