From 2579e9014e46b3977539c84575f77538c5fb7764 Mon Sep 17 00:00:00 2001 From: dead_horse Date: Fri, 27 Dec 2013 17:48:22 +0800 Subject: [PATCH] fix hasOwnProperty usage see https://github.com/joyent/node/issues/1707#issuecomment-2106309 --- lib/module.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/lib/module.js b/lib/module.js index a9dc1f2..6c6f3e4 100644 --- a/lib/module.js +++ b/lib/module.js @@ -38,6 +38,11 @@ var _nativeNames = [ 'url', ]; +// See: https://github.com/joyent/node/issues/1707#issuecomment-2106309 +function hasOwnProperty(obj, prop) { + return Object.prototype.hasOwnProperty.call(obj, prop); +} + function initConfig() { _cacheModules = {}; _disableModules = {}; @@ -84,13 +89,13 @@ exports._findPath = Module._findPath; exports._resolveFilename = function (request, parent) { debug('SandboxModule._resolveFilename %s parent: %s', request, parent && parent.id); - if (_disableModules.hasOwnProperty(request)) { + if (hasOwnProperty(_disableModules, request)) { var err = new Error("Disable module '" + request + "'"); err.code = 'MODULE_DISABLE'; throw err; } - if (_nativeModules.hasOwnProperty(request)) { + if (hasOwnProperty(_nativeModules, request)) { return request; } @@ -134,7 +139,7 @@ exports._load = function (request, parent, isMain) { var filename = exports._resolveFilename(request, parent); // check native modules first - if (_nativeModules.hasOwnProperty(filename)) { + if (hasOwnProperty(_nativeModules, filename)) { debug('SandboxModule._load native module %s', request); return _nativeModules[filename]; }