diff --git a/index.js b/index.js index d5de238..a75eced 100644 --- a/index.js +++ b/index.js @@ -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; +}; diff --git a/README.markdown b/readme.markdown similarity index 100% rename from README.markdown rename to readme.markdown