Comparing version 1.2.3 to 1.3.1
11
index.js
@@ -43,3 +43,3 @@ function isObject (o) { | ||
function map (obj, iter, out) { | ||
var out = out || {} | ||
var out = out || Array.isArray(obj) ? [] : {} | ||
each(obj, function (val, path) { | ||
@@ -59,2 +59,8 @@ set(out, path, iter(val, path)) | ||
function id (e) { return e } | ||
function clone (obj) { | ||
return map(obj, id) | ||
} | ||
exports.get = get | ||
@@ -65,3 +71,2 @@ exports.set = set | ||
exports.paths = paths | ||
exports.clone = clone |
{ | ||
"name": "libnested", | ||
"description": "", | ||
"version": "1.2.3", | ||
"version": "1.3.1", | ||
"homepage": "https://github.com/dominictarr/libnested", | ||
@@ -6,0 +6,0 @@ "repository": { |
@@ -28,10 +28,17 @@ # libnested | ||
`path` may be an array of strings or numbers, or a single string or number. | ||
### set(object, path, value) | ||
set `value` at location `path` within `object`. | ||
If path is deeper than object goes, intermediate `{}`'s are added. | ||
If path is deeper than object goes, intermediate `{}`'s are added. | ||
`path` may be an array of strings or numbers, or a single string or number. | ||
### clone (object) | ||
return a new object with the same structure and primitive values as `object` | ||
## License | ||
MIT |
13
test.js
@@ -88,2 +88,13 @@ | ||
t.deepEqual( | ||
deep, | ||
R.clone(deep) | ||
) | ||
t.notEqual( | ||
deep, | ||
R.clone(deep) | ||
) | ||
t.end() | ||
@@ -94,1 +105,3 @@ | ||
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
5760
139
44