copy-deep
v1.0.0
Published
Used to do deep copy of objects and arrays (among others)
Downloads
29
Maintainers
Readme
copy-deep
Setup
Add
copy-deep
dependency using yarn or npm to your projectWith yarn:
yarn add copy-deep
With npm:
npm install --save copy-deep
Usage
You can either use the function as the default import or as a partial import
default import
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)
Partial import
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)