Skip to content

Commit

Permalink
hasOwnProperty stub
Browse files Browse the repository at this point in the history
  • Loading branch information
James Halliday committed Dec 17, 2012
1 parent 5c8e966 commit c889666
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Traverse.prototype.get = function (ps) {
var node = this.value;
for (var i = 0; i < ps.length; i ++) {
var key = ps[i];
if (!Object.hasOwnProperty.call(node, key)) {
if (!hasOwnProperty.call(node, key)) {
node = undefined;
break;
}
Expand All @@ -23,7 +23,7 @@ Traverse.prototype.has = function (ps) {
var node = this.value;
for (var i = 0; i < ps.length; i ++) {
var key = ps[i];
if (!Object.hasOwnProperty.call(node, key)) {
if (!hasOwnProperty.call(node, key)) {
return false;
}
node = node[key];
Expand All @@ -35,7 +35,7 @@ Traverse.prototype.set = function (ps, value) {
var node = this.value;
for (var i = 0; i < ps.length - 1; i ++) {
var key = ps[i];
if (!Object.hasOwnProperty.call(node, key)) node[key] = {};
if (!hasOwnProperty.call(node, key)) node[key] = {};
node = node[key];
}
node[ps[i]] = value;
Expand Down Expand Up @@ -206,7 +206,7 @@ function walk (root, cb, immutable) {
if (modifiers.pre) modifiers.pre.call(state, state.node[key], key);

var child = walker(state.node[key]);
if (immutable && Object.hasOwnProperty.call(state.node, key)) {
if (immutable && hasOwnProperty.call(state.node, key)) {
state.node[key] = child.node;
}

Expand Down Expand Up @@ -308,3 +308,7 @@ forEach(objectKeys(Traverse.prototype), function (key) {
return t[key].apply(t, args);
};
});

var hasOwnProperty = Object.hasOwnProperty || function (obj, key) {
return key in obj;
};
File renamed without changes.

0 comments on commit c889666

Please sign in to comment.