Skip to content
This repository has been archived by the owner. It is now read-only.
Permalink
Browse files

Fix #1707 hasOwnProperty usage

  • Loading branch information...
isaacs committed Sep 15, 2011
1 parent 5724b54 commit 98990b97798f2bd46416df03f6f8b8a192feb9b9
Showing with 20 additions and 3 deletions.
  1. +7 −1 lib/module.js
  2. +6 −1 lib/querystring.js
  3. +7 −1 lib/repl.js
@@ -25,6 +25,12 @@ var runInThisContext = Script.runInThisContext;
var runInNewContext = Script.runInNewContext;
var assert = require('assert').ok;


function hOP(obj, prop) {

This comment has been minimized.

Copy link
@felixge

felixge Sep 15, 2011

What's up with the cryptic function name? I have no idea what this does without looking up the actual hOP function.

This comment has been minimized.

Copy link
@ry

ry Sep 15, 2011

I agree with felixge

This comment has been minimized.

Copy link
@ry

ry Sep 15, 2011

we should have a comment about why this is being done and preferably a link to the issue and (yet non-existant) test

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];
}

@@ -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];
@@ -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;
}

0 comments on commit 98990b9

Please sign in to comment.
You can’t perform that action at this time.