4.0.1 • Published 5 years ago

clone-deep v4.0.1

Weekly downloads
11,169,714
License
MIT
Repository
github
Last release
5 years ago

clone-deep NPM version NPM monthly downloads NPM total downloads Linux Build Status

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

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 isPlainObjectisPlainObject). 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

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:

Contributors

CommitsContributor
46jonschlinkert
2yujunlong2000

Author

Jon Schlinkert

License

Copyright © 2018, Jon Schlinkert. Released under the MIT License.


This file was generated by verb-generate-readme, v0.8.0, on November 21, 2018.

webpack-merge@babel/registermerge-deeplerna@lerna/command@lerna/createfree-minarchetype-library@germanamz/pack-lambdadesign-iuap-expressioncomponennentt@titaui/pceasy-select-rnj-crud-vue3bpmn-editor-wjbpmn-editor-wujincommie-service@braid/nuxt-cms@cashremit/cr-streamline-iconsschema-ohhc-stuffilitohezhouyuanrenchaincl-crud-asolilu@itnikc/legend-bpmn-editoralpha-weblegend-bpmn-editorbb-chater-prism-web@frxf/frxf@fundefund/funde_ck@ntt_app/react-native-custom-notificationreact-native-custom-text-hwjamesreact-native-covid-sdktemplyr-npm-apioasis-game-client-proxyplot-packglobaltruck-uikit1react-native-printer-brotherscbmis-ai-toolboxant-crud-nextreact-native-shekhar-bridge-testaso-admin-nextaso.crudcogoportutilslevibestliblevibestlib2levilibtest19levilibtest24levilibtest25levilibtest26levilibtest27levilibtest28levilibtest29wilscanner@oiti/documentoscopy-react-nativejs4cytoscapequoc-testvnk-core-vite-1vnk-core-vite-2@icmaa/storefront-query-builderreact-native-slider-kfunblock-block-save-variables@infinitebrahmanuniverse/nolb-cloncclibyarntest@saaspe/components@candidpartners/tf-parsehyperpass-sdkcontracter-jsprocare-nordic-apinode-red-contrib-home-assistant-llatluminos-ui-corelamlhagcp-reduxsklif-ui-kitsklif-api@everything-registry/sub-chunk-1339jawwy-sdkjawwy_gamification_releasemycryptolibreact-native-sphereuisphereuijawwy_libraryreact-native-credit-card-pkgsklif-uireact-native-jawwy_samplereact-native-chenaarstore-cachepayutestingreact-data-dam@dskdavid/flash_clieslint-disableeslint-plugin-xunitfawaterak-online-paymentfawatrak-online-paymentfigma-api-stubfmslfn-lib-exampleethdeployest-less-loaderfootloose-client
4.0.1

5 years ago

4.0.0

6 years ago

2.0.2

6 years ago

3.0.1

6 years ago

3.0.0

6 years ago

2.0.1

6 years ago

2.0.0

6 years ago

1.0.0

7 years ago

0.3.0

7 years ago

0.2.4

8 years ago

0.2.3

9 years ago

0.2.2

9 years ago

0.2.1

9 years ago

0.2.0

9 years ago

0.1.1

10 years ago

0.1.0

10 years ago