Permalink
Browse files

hasOwnProperty stub

  • Loading branch information...
1 parent 5c8e966 commit c889666d81d79cbfd99372bea641e6938bd5531c @substack committed Dec 17, 2012
Showing with 8 additions and 4 deletions.
  1. +8 −4 index.js
  2. 0 README.markdown → readme.markdown
View
@@ -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;
}
@@ -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];
@@ -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;
@@ -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;
}
@@ -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.