copy-deep
Version:
Used to do deep copy of objects and arrays (among others)
63 lines (44 loc) • 1.18 kB
Markdown
//img.shields.io/github/license/Vinccool96/copy-deep)](./LICENSE)
[](https://npmjs.com/package/copy-deep)
[](https://npmjs.com/package/copy-deep)
- Add `copy-deep` dependency using yarn or npm to your project
With yarn:
```sh
yarn add copy-deep
```
With npm:
```sh
npm install --save copy-deep
```
You can either use the function as the default import or as a partial import
```ts
import copyDeep from "copy-deep"
const initial = {
foo: "bar",
toto: true,
honestly: ["it", { just: "works" }],
tata() {
return !this.toto
},
}
const notExtensible = Object.preventExtensions(initial)
const clone = copyDeep(notExtensible)
```
```ts
import { copyDeep } from "copy-deep"
const initial = {
foo: "bar",
toto: true,
honestly: ["it", { just: "works" }],
tata() {
return !this.toto
},
}
const notExtensible = Object.preventExtensions(initial)
const clone = copyDeep(notExtensible)
```
[![](https: