1.0.0 • Published 1 year ago

copy-deep v1.0.0

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

copy-deep

npm.io npm (scoped with tag) npm

Setup

  • Add copy-deep dependency using yarn or npm to your project

    With 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)