Package detail

just-clone

angus-c573kMIT6.2.0

deep copies objects and arrays

object, clone, copy, deep-copy

readme

just-clone

Part of a library of zero-dependency npm modules that do just do one thing. Guilt-free utilities for every occasion.

🍦 Try it

npm install just-clone
yarn add just-clone

Deep copies objects, arrays, maps and sets

// Deep copies objects and arrays, doesn't clone functions

import clone from 'just-clone';

var arr = [1, 2, 3];
var subObj = { aa: 1 };
var obj = { a: 3, b: 5, c: arr, d: subObj };
var objClone = clone(obj);
arr.push(4);
objClone.d.bb = 2;
obj; // {a: 3, b: 5, c: [1, 2, 3, 4], d: {aa: 1}}
objClone; // {a: 3, b: 5, c: [1, 2, 3], d: {aa: 1, bb: 2}}

changelog

just-clone

6.2.0

Minor Changes

  • Rename node module .js -> .cjs

6.1.1

Patch Changes

  • fix: reorder exports to set default last #488

6.1.0

Minor Changes

  • package.json updates to fix #467 and #483

6.0.1

Patch Changes

  • Keep ESMs in sync with commonJS modules

6.0.0

Major Changes

  • 7dc1f05a: Supports Deep Cloning of Sets and Maps (Major bump due to reduced legacy ES support)

5.1.0

Minor Changes

  • Support cloning Maps and Sets