Comparing version 0.0.5 to 0.0.6
@@ -85,2 +85,15 @@ /* | ||
// | ||
// given an object, set value at path, creating objects if necessary. | ||
// | ||
exports.createPath = function (object, path, value) { | ||
for (var i in path) { | ||
var key = path[i]; | ||
if(!object[key]) object[key] = ((+i + 1 == path.length) ? value : {}); | ||
object = object[key]; | ||
} | ||
} | ||
// | ||
// ### function mixin (target [source0, source1, ...]) | ||
@@ -87,0 +100,0 @@ // Copies enumerable properties from `source0 ... sourceN` |
{ | ||
"name": "utile", | ||
"description": "A drop-in replacement for `util` with some additional advantageous functions", | ||
"version": "0.0.5", | ||
"version": "0.0.6", | ||
"author": "Nodejitsu Inc <info@nodejitsu.com>", | ||
@@ -6,0 +6,0 @@ "contributors": [ |
@@ -54,4 +54,10 @@ /* | ||
assert.notStrictEqual(obj1, clone); | ||
}, | ||
"the createPath() method": function () { | ||
var x = {} | ||
, r = Math.random() | ||
utile.createPath(x, ['a','b','c'], r) | ||
assert.equal(x.a.b.c, r) | ||
} | ||
} | ||
}).export(module); |
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
13029
296