nanoclone

300B to deep clone JavaScript objects

MIT 11 个版本
安装
npm install nanoclone
yarn add nanoclone
pnpm add nanoclone
bun add nanoclone
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

  • Primitives
  • Arrays
  • Plain objects
  • DOM Nodes
  • Date instances
  • RegExp instances
  • Maps
  • Sets
  • 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

版本列表
1.0.2 2023-05-11
1.0.1 2022-10-31
1.0.0 2021-10-29
0.2.1 2018-02-19
0.2.0 2018-01-23
0.1.5 2018-01-05
0.1.4 2018-01-05
0.1.3 2017-12-31
0.1.2 2017-11-24
0.1.1 2017-11-24
0.1.0 2017-11-24