6.0.0 • Published 4 years ago

deep-clone-util v6.0.0

Weekly downloads
6
License
ISC
Repository
github
Last release
4 years ago

deep-clone-util

Utility to deep clone javascript objects

npm version Node.js CI

Clone - JS utility to deep clone an object

With deep cloning becoming a regular practice & a required thing for supporting immutability, deep-clone-util provides a way just to do that.

  • No dependeny on any library
  • 2kB of unzipped bundle size

    Supports cloning of:

  • Elementary values

  • Array, Objects (nesting upto any level)
  • Functions
  • Promises
  • Dates
  • Regular expressions
  • Maps & Sets

    Todo

  • Support circular references

  • Suppprt more object types

    Installation

    npm i deep-clone-util

Examples

const clone = require('deep-clone-util');
const obj = {
 a: 1,
 b: "string",
 c: function(a) {console.log(a)},
 d: [1,2,3],
 f: {
  g: 1
 }
}

const clonedObj = clone(obj)
obj.f.g = 10
console.log(obj.f.g) // Prints 1

Contributions

  • Author: Gaurav Behere
  • Please raise a PR, if you see some improvement possible.