shadow-copy

1.0.0 • Public • Published

Build Status

shadow-copy

Creates a shadow copy of an object by using prototype.

Install

$ npm install shadow-copy --save

Usage

var copy = require('shadow-copy');

var obj = {
  a: 1
};

var copied = copy(obj);
copied.a;     // 1
copied.a = 2;

obj.a;        // still 1

copy.deep(obj)

Deeply clone a object by using prototype

var obj = {
  a: {
    a: 1
  }
};

copy.deep(obj).a.a = 2;
obj.a.a;                // still 1

copy(obj).a.a = 2;
obj.a.a;                // 1
                        // `copy()` only copy the first level of an object

License

MIT

Package Sidebar

Install

npm i shadow-copy

Weekly Downloads

0

Version

1.0.0

License

MIT

Last publish

Collaborators

  • kael