|
|
6 kuukautta sitten | |
|---|---|---|
| .. | ||
| LICENSE | 6 kuukautta sitten | |
| README.md | 6 kuukautta sitten | |
| index.js | 6 kuukautta sitten | |
| package.json | 6 kuukautta sitten | |
Recursively (deep) clone JavaScript native types, like Object, Array, RegExp, Date as well as primitives.
Please consider following this project's author, Jon Schlinkert, and consider starring the project to show your :heart: and support.
Install with npm:
$ npm install --save clone-deep
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'}]
The instanceClone function is invoked to clone objects that are not "plain" objects (as defined by isPlainObjectisPlainObject) if it is provided. If instanceClone is not specified, it will not attempt to clone non-plain objects, and will copy the object reference.
Based on mout's implementation of deepClone.
You might also be interested in these projects:
Object constructor. | homepageJon Schlinkert
Copyright © 2017, Jon Schlinkert. Released under the MIT License.
This file was generated by verb-generate-readme, v0.6.0, on November 16, 2017.