JSPM

js.clone

0.0.3
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 81
  • Score
    100M100P100Q63802F
  • License MIT

Deep clone any object with circular references

Package Exports

  • js.clone

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (js.clone) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

Install

npm install js.clone --save

Usage

import Clone from "js.clone";

var a, b, c;

a = {
    null:     null,
    boolean:  true,
    number:   1,
    string:   "string",
    regexp:   /regexp/,
    function: function(){},
    array:    ["array"],
    object:   {foo: "bar"}
}

b = Clone( a );

a == b // false

a.array.push( 1 );
a.array // > ["array", 1]
b.array // > ["array"]

// Circular links

a.circular = a;
a.circular === a          // > true
c = Clone( a );
c.circular === c          // > true
c.circular === a.circular // > false