Skip to content

Commit

Permalink
Make .get and .set work with Objects that have a prototype
Browse files Browse the repository at this point in the history
  • Loading branch information
jauco committed Feb 23, 2015
1 parent 5d3e2a7 commit 12ea5ba
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ api.get = function get (obj, pointer) {
refTokens = api.parse(pointer);
while (refTokens.length) {
tok = refTokens.shift();
if (!obj.hasOwnProperty(tok)) {
if (!(tok in obj)) {
throw new Error('Invalid reference token: ' + tok);
}
obj = obj[tok];
Expand All @@ -76,7 +76,7 @@ api.set = function set (obj, pointer, value) {
}
nextTok = refTokens[0];

if (!obj.hasOwnProperty(tok)) {
if (!(tok in obj)) {
if (nextTok.match(/^(\d+|-)$/)) {
obj[tok] = [];
} else {
Expand Down

0 comments on commit 12ea5ba

Please sign in to comment.