object-templates
v1.0.7
Published
Object templates like string templates but for object
Downloads
3
Maintainers
Readme
clone-deep
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
Install with npm:
$ npm install --save clone-deep
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'}]
Heads up!
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.
Attribution
Based on mout's implementation of deepClone.
About
Pull requests and stars are always welcome. For bugs and feature requests, please create an issue.
Running and reviewing unit tests is a great way to get familiarized with a library and its API. You can install dependencies and run tests with the following command:
$ npm install && npm test
(This project's readme.md is generated by verb, please don't edit the readme directly. Any changes to the readme must be made in the .verb.md readme template.)
To generate the readme, run the following command:
$ npm install -g verbose/verb#dev verb-generate-readme && verb
Related projects
You might also be interested in these projects:
- is-plain-object: Returns true if an object was created by the
Object
constructor. | homepage - isobject: Returns true if the value is an object and not an array or null. | homepage
- kind-of: Get the native type of a value. | homepage
- shallow-clone: Creates a shallow clone of any JavaScript value. | homepage
Author
Jon Schlinkert
License
Copyright © 2018, Jon Schlinkert. Released under the MIT License.
This file was generated by verb-generate-readme, v0.6.0, on April 10, 2018.