Comparing version 1.0.2 to 1.1.0
19
index.js
@@ -34,5 +34,20 @@ var natives = process.binding('natives') | ||
// calls made throughout the internal module load IS cached. | ||
function req (id) { | ||
return req_(id, Object.create(null)) | ||
function req (id, whitelist) { | ||
var cache = Object.create(null) | ||
if (Array.isArray(whitelist)) { | ||
// a whitelist of things to pull from the "actual" native modules | ||
whitelist.forEach(function (id) { | ||
cache[id] = { | ||
loading: false, | ||
loaded: true, | ||
filename: id + '.js', | ||
exports: require(id) | ||
} | ||
}) | ||
} | ||
return req_(id, cache) | ||
} | ||
function req_ (id, cache) { | ||
@@ -39,0 +54,0 @@ // Buffer is special, because it's a type rather than a "normal" |
{ | ||
"name": "natives", | ||
"version": "1.0.2", | ||
"version": "1.1.0", | ||
"description": "Do stuff with Node.js's native JavaScript modules", | ||
"main": "index.js", | ||
"scripts": { | ||
"test": "tap test/*.js --branches=100 --lines=100 --statements=100 --functions=100" | ||
"test": "tap test/*.js --100" | ||
}, | ||
@@ -20,3 +20,3 @@ "repository": { | ||
"devDependencies": { | ||
"tap": "^6.3.2" | ||
"tap": "^7.0.0" | ||
}, | ||
@@ -23,0 +23,0 @@ "files": [ |
@@ -50,2 +50,5 @@ # natives | ||
// you can pass in a whitelist to NOT shim certain things | ||
var fsCopyWithNativeStreams = natives.require('fs', ['stream']) | ||
// note that this is not the same as the "real" fs | ||
@@ -52,0 +55,0 @@ assert(fsCopy !== require('fs')) |
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
5401
102
65
4