Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

nanoclone

kelin202510.2mMIT1.0.2TypeScript support: included

300B to deep clone JavaScript objects

clone, deep, nano, nanoclone, deepclone

readme

nanoclone

license npm
Only 300B to deep clone JavaScript objects

Is it small enough?

See the size of the most popular clone npm package with 250M+ downloads image
And nanoclone size:
image

Supported

  • <input checked="" disabled="" type="checkbox"> Primitives
  • <input checked="" disabled="" type="checkbox"> Arrays
  • <input checked="" disabled="" type="checkbox"> Plain objects
  • <input checked="" disabled="" type="checkbox"> DOM Nodes
  • <input checked="" disabled="" type="checkbox"> Date instances
  • <input checked="" disabled="" type="checkbox"> RegExp instances
  • <input checked="" disabled="" type="checkbox"> Maps
  • <input checked="" disabled="" type="checkbox"> Sets
  • <input checked="" disabled="" type="checkbox"> Circular structures

Installation

yarn add nanoclone
npm install nanoclone

Usage

import clone from 'nanoclone'

let a = {
  num: 2,
  arr: [1, 2, 3],
  nested: {
    obj: {
      a: 0
    }
  }
}

let b = clone(a)

License

MIT