diff options
Diffstat (limited to 'lib/utils.js')
-rw-r--r-- | lib/utils.js | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/lib/utils.js b/lib/utils.js index 4612a322..c81ca71f 100644 --- a/lib/utils.js +++ b/lib/utils.js @@ -97,17 +97,17 @@ function defaults(args, defs, croak) { if (args === true) args = {}; var ret = args || {}; - if (croak) for (var i in ret) if (ret.hasOwnProperty(i) && !defs.hasOwnProperty(i)) + if (croak) for (var i in ret) if (HOP(ret, i) && !HOP(defs, i)) DefaultsError.croak("`" + i + "` is not a supported option", defs); - for (var i in defs) if (defs.hasOwnProperty(i)) { - ret[i] = (args && args.hasOwnProperty(i)) ? args[i] : defs[i]; + for (var i in defs) if (HOP(defs, i)) { + ret[i] = (args && HOP(args, i)) ? args[i] : defs[i]; } return ret; }; function merge(obj, ext) { var count = 0; - for (var i in ext) if (ext.hasOwnProperty(i)) { + for (var i in ext) if (HOP(ext, i)) { obj[i] = ext[i]; count++; } @@ -150,7 +150,7 @@ var MAP = (function(){ } } else { - for (i in a) if (a.hasOwnProperty(i)) if (doit()) break; + for (i in a) if (HOP(a, i)) if (doit()) break; } return top.concat(ret); }; @@ -308,3 +308,7 @@ Dictionary.fromObject = function(obj) { dict._size = merge(dict._values, obj); return dict; }; + +function HOP(obj, prop) { + return Object.prototype.hasOwnProperty.call(obj, prop); +} |