diff --git a/index.js b/index.js index 7b238dd..ff2599a 100644 --- a/index.js +++ b/index.js @@ -91,13 +91,11 @@ module.exports = function requireDir(dir, opts) { continue; } - // Node v8+ uses "clean" objects w/o hasOwnProperty for require - var hasExt = require.extensions.hasOwnProperty || function(ext) { return require.extensions[ext]; }; - // otherwise, go through and try each require.extension key! for (ext in require.extensions) { + // Node v8+ uses "clean" objects w/o hasOwnProperty for require // again protect against enumerable object prototype extensions: - if (!hasExt(ext)) { + if (!Object.prototype.hasOwnProperty.call(require.extensions, ext)) { continue; }