From 98990b97798f2bd46416df03f6f8b8a192feb9b9 Mon Sep 17 00:00:00 2001 From: isaacs Date: Thu, 15 Sep 2011 09:46:30 -0700 Subject: [PATCH] Fix #1707 hasOwnProperty usage --- lib/module.js | 8 +++++++- lib/querystring.js | 7 ++++++- lib/repl.js | 8 +++++++- 3 files changed, 20 insertions(+), 3 deletions(-) diff --git a/lib/module.js b/lib/module.js index 11c5189..650f340 100644 --- a/lib/module.js +++ b/lib/module.js @@ -25,6 +25,12 @@ var runInThisContext = Script.runInThisContext; var runInNewContext = Script.runInNewContext; var assert = require('assert').ok; + +function hOP(obj, prop) { + return Object.prototype.hasOwnProperty.call(obj, prop); +} + + function Module(id, parent) { this.id = id; this.exports = {}; @@ -85,7 +91,7 @@ function statPath(path) { var packageCache = {}; function readPackage(requestPath) { - if (packageCache.hasOwnProperty(requestPath)) { + if (hOP(packageCache, requestPath)) { return packageCache[requestPath]; } diff --git a/lib/querystring.js b/lib/querystring.js index 0effe5b..e8796e4 100644 --- a/lib/querystring.js +++ b/lib/querystring.js @@ -25,6 +25,11 @@ var QueryString = exports; var urlDecode = process.binding('http_parser').urlDecode; +function hOP(obj, prop) { + return Object.prototype.hasOwnProperty.call(obj, prop); +} + + function charCode(c) { return c.charCodeAt(0); } @@ -166,7 +171,7 @@ QueryString.parse = QueryString.decode = function(qs, sep, eq) { var k = QueryString.unescape(x[0], true); var v = QueryString.unescape(x.slice(1).join(eq), true); - if (!obj.hasOwnProperty(k)) { + if (!hOP(obj, k)) { obj[k] = v; } else if (!Array.isArray(obj[k])) { obj[k] = [obj[k], v]; diff --git a/lib/repl.js b/lib/repl.js index ffe2b77..3a9cae0 100644 --- a/lib/repl.js +++ b/lib/repl.js @@ -46,6 +46,12 @@ var path = require('path'); var fs = require('fs'); var rl = require('readline'); + +function hOP(obj, prop) { + return Object.prototype.hasOwnProperty.call(obj, prop); +} + + var context; var disableColors = true; @@ -446,7 +452,7 @@ REPLServer.prototype.complete = function(line) { group.sort(); for (var j = 0; j < group.length; j++) { c = group[j]; - if (!uniq.hasOwnProperty(c)) { + if (!hOP(uniq, c)) { completions.push(c); uniq[c] = true; } -- 2.7.4