Comparing version 1.0.4 to 1.0.5
module.exports.set = set | ||
module.exports.unset = unset | ||
module.exports.get = get | ||
@@ -9,3 +10,3 @@ | ||
function set(obj, key, value, overwrite) { | ||
function lookup(obj, key) { | ||
key = parts(key) | ||
@@ -19,5 +20,19 @@ var lastKey = key.pop() | ||
} | ||
if (overwrite || !(lastKey in obj)) obj[lastKey] = value | ||
return [obj, lastKey]; | ||
} | ||
function set(obj, key, value, overwrite) { | ||
var objectAndKey = lookup(obj, key) | ||
, obj = objectAndKey[0] | ||
, key = objectAndKey[1]; | ||
if (overwrite || !(key in obj)) obj[key] = value | ||
} | ||
function unset(obj, key) { | ||
var objectAndKey = lookup(obj, key) | ||
, obj = objectAndKey[0] | ||
, key = objectAndKey[1]; | ||
return delete obj[key]; | ||
} | ||
function get(obj, key, def) { | ||
@@ -24,0 +39,0 @@ key = parts(key) |
{ | ||
"name": "dotaccess", | ||
"description": "A library to access objects using dot notation strings.", | ||
"version": "1.0.4", | ||
"version": "1.0.5", | ||
"homepage": "https://github.com/daaku/nodejs-dotaccess", | ||
@@ -6,0 +6,0 @@ "author": "Naitik Shah <n@daaku.org>", |
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
2365
39
0