lutils-clone
Advanced tools
Comparing version 0.1.3 to 0.1.4
{ | ||
"name" : "lutils-clone", | ||
"description" : "Reliably and recursively clone javascript objects", | ||
"version" : "0.1.3", | ||
"version" : "0.1.4", | ||
"author" : { "name": "nfour" }, | ||
@@ -6,0 +6,0 @@ "repository" : { |
# clone `lutils-clone` | ||
Reliably and recursively clone javascript objects | ||
`npm install lutils-clone` | ||
## API | ||
@@ -9,24 +11,26 @@ | ||
```js | ||
import clone from 'lutils-clone' | ||
var test = new class Test {} | ||
const test = new class Test {} | ||
var obj = { | ||
a: { b: 2 }, | ||
const obj = { | ||
a : { b: 2 }, | ||
fn : function() {} | ||
test, | ||
fn: function() {} | ||
} | ||
var newObj = clone(obj) | ||
const newObj = clone(obj) | ||
newObj.a.b = 5 // 5 | ||
obj.a.b // 2 | ||
newObj.a === obj.a // false | ||
newObj.test === test // false | ||
newObj.a.b = 5 // 5 | ||
obj.a.b // 2 | ||
newObj.a === obj.a // false | ||
newObj.test === test // false | ||
newObj.test.__proto__ === test.__proto__ // true | ||
newObj.fn === obj.fn // true | ||
newObj.fn === obj.fn // true | ||
``` | ||
## Advanced usage | ||
### Options | ||
@@ -33,0 +37,0 @@ ```js |
3422
47