rOACCT/node_modules/clone-deepdd570dbc4621master
clone-deep
README.md
clone-deep ![NPM version](https://www.npmjs.com/package/clone-deep) ![NPM monthly downloads](https://npmjs.org/package/clone-deep) ![NPM total downloads](https://npmjs.org/package/clone-deep) ![Linux Build Status](https://travis-ci.org/jonschlinkert/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 ❤️ and support.
Install
Install with npm:
sh $ npm install --save clone-deep
Usage
js const cloneDeep = require('clone-deep'); let obj = { a: 'b' }; let arr = [obj]; let copy = cloneDeep(arr); obj.c = 'd'; console.log(copy); //=> [{ a: 'b' }] console.log(arr); //=> [{ a: 'b', c: 'd' }]
Heads up!
The last argument specifies whether or not to clone instances (objects that are from a custom class or are not created by the Object constructor. This value may be true or the function use for cloning instances.
When an instanceClone function is provided, it will be invoked to clone objects that are not "plain" objects (as defined by [isPlainObject](#isPlainObject)isPlainObject). If instanceClone is not specified, this library will not attempt to clone non-plain objects, and will simply copy the object reference.
Attribution
Initially based on mout's implementation of deepClone.
About
<details> <summary><strong>Contributing</strong></summary>
Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](../../issues/new).
</details>
<details> <summary><strong>Running Tests</strong></summary>
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:
sh $ npm install && npm test
</details>
<details> <summary><strong>Building docs</strong></summary>
_(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](.verb.md) readme template.)_
To generate the readme, run the following command:
sh $ npm install -g verbose/verb#dev verb-generate-readme && verb
</details>
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](https://github.com/jonschlinkert/is-plain-object "Returns true if an object was created by the Object constructor.")
- isobject: Returns true if the value is an object and not an array or null. | [homepage](https://github.com/jonschlinkert/isobject "Returns true if the value is an object and not an array or null.")
- kind-of: Get the native type of a value. | [homepage](https://github.com/jonschlinkert/kind-of "Get the native type of a value.")
- shallow-clone: Creates a shallow clone of any JavaScript value. | [homepage](https://github.com/jonschlinkert/shallow-clone "Creates a shallow clone of any JavaScript value.")
Contributors
Commits | Contributor | |
---|---|---|
46 | jonschlinkert | |
2 | yujunlong2000 | |
Author
Jon Schlinkert
License
Copyright © 2018, Jon Schlinkert. Released under the [MIT License](LICENSE).
_This file was generated by verb-generate-readme, v0.8.0, on November 21, 2018._