Blame view

node_modules/clone-deep/README.md 3.75 KB
aaac7fed   liuqimichale   add
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
  # clone-deep [![NPM version](https://img.shields.io/npm/v/clone-deep.svg?style=flat)](https://www.npmjs.com/package/clone-deep) [![NPM monthly downloads](https://img.shields.io/npm/dm/clone-deep.svg?style=flat)](https://npmjs.org/package/clone-deep) [![NPM total downloads](https://img.shields.io/npm/dt/clone-deep.svg?style=flat)](https://npmjs.org/package/clone-deep) [![Linux Build Status](https://img.shields.io/travis/jonschlinkert/clone-deep.svg?style=flat&label=Travis)](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](https://github.com/jonschlinkert), and consider starring the project to show your :heart: and support.
  
  ## Install
  
  Install with [npm](https://www.npmjs.com/):
  
  ```sh
  $ npm install --save clone-deep
  ```
  
  ## Usage
  
  ```js
  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 [isPlainObject](#isPlainObject)`isPlainObject`) 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](https://github.com/mout/mout) 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](https://github.com/verbose/verb-generate-readme), 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](https://www.npmjs.com/package/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](https://www.npmjs.com/package/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](https://www.npmjs.com/package/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](https://www.npmjs.com/package/shallow-clone): Make a shallow clone of an object, array or primitive. | [homepage](https://github.com/jonschlinkert/shallow-clone "Make a shallow clone of an object, array or primitive.")
  
  ### Author
  
  **Jon Schlinkert**
  
  * [github/jonschlinkert](https://github.com/jonschlinkert)
  * [twitter/jonschlinkert](https://twitter.com/jonschlinkert)
  
  ### License
  
  Copyright © 2017, [Jon Schlinkert](https://github.com/jonschlinkert).
  Released under the [MIT License](LICENSE).
  
  ***
  
  _This file was generated by [verb-generate-readme](https://github.com/verbose/verb-generate-readme), v0.6.0, on November 16, 2017._