Browse files

v0.0.3

  • Loading branch information...
1 parent 64877f9 commit fb5d6b0c402aea888a82567efb70bbb379c3c770 @guybrush committed Feb 14, 2012
Showing with 5 additions and 2 deletions.
  1. +4 −1 objpath.js
  2. +1 −1 package.json
View
5 objpath.js
@@ -31,22 +31,25 @@ function objpath(obj, keyString, value) {
if (value === undefined) { // get data
var value = temp
for (var i=0, len=keys.length; i<len; i++) {
- if (value === undefined) return false
+ if (value[keys[i]] === undefined) return false
value = value[keys[i]]
}
return value
} else { // set data
if (keys.length==0) {
obj[keyString] = value
+ //console.log(obj)
return obj
}
for (var i=0, len=keys.length; i<len; i++) {
if (i==(len-1)) {
temp[keys[i]] = value
} else {
+ temp[keys[i]] = temp[keys[i]] || {}
temp = temp[keys[i]]
}
}
+ //console.log(obj)
return obj
}
}
View
2 package.json
@@ -1,5 +1,5 @@
{ "name" : "objpath"
-, "version" : "0.0.2"
+, "version" : "0.0.3"
, "main" : "./objpath.js"
, "scripts" :
{ "test" : "./node_modules/.bin/mocha ./test.js -u exports -R spec" }

0 comments on commit fb5d6b0

Please sign in to comment.