Socket
Socket
Sign inDemoInstall

module-deps

Package Overview
Dependencies
Maintainers
7
Versions
139
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

module-deps - npm Package Compare versions

Comparing version 4.0.8 to 4.1.0

test/cache_persistent.js

62

index.js

@@ -30,2 +30,7 @@ var fs = require('fs');

this.basedir = opts.basedir || process.cwd();
this.persistentCache = opts.persistentCache || function (file, id, pkg, fallback, cb) {
setImmediate(function () {
fallback(null, cb);
});
};
this.cache = opts.cache;

@@ -200,6 +205,3 @@ this.fileCache = opts.fileCache;

if (xhas(this.fileCache, file)) {
var tr = through();
tr.push(this.fileCache[file]);
tr.push(null);
return tr;
return toStream(this.fileCache[file]);
}

@@ -381,15 +383,40 @@ var rs = fs.createReadStream(file, {

self.readFile(file, id, pkg)
.pipe(self.getTransforms(fakePath || file, pkg, {
builtin: builtin,
inNodeModules: parent.inNodeModules
}))
.pipe(concat(function (body) {
fromSource(file, body.toString('utf8'), pkg, fakePath);
}))
;
self.persistentCache(file, id, pkg, persistentCacheFallback, function (err, c) {
if (err) {
self.emit('error', err);
return;
}
fromDeps(file, c.source, c.package, fakePath, Object.keys(c.deps));
});
function persistentCacheFallback (dataAsString, cb) {
var stream = dataAsString ? toStream(dataAsString) : self.readFile(file, id, pkg);
stream
.pipe(self.getTransforms(fakePath || file, pkg, {
builtin: builtin,
inNodeModules: parent.inNodeModules
}))
.pipe(concat(function (body) {
var src = body.toString('utf8');
var deps = getDeps(file, src);
if (deps) {
cb(null, {
source: src,
package: pkg,
deps: deps.reduce(function (deps, dep) {
deps[dep] = true;
return deps;
}, {})
});
}
}));
}
});
function getDeps (file, src) {
return rec.noparse ? [] : self.parseDeps(file, src);
}
function fromSource (file, src, pkg, fakePath) {
var deps = rec.noparse ? [] : self.parseDeps(file, src);
var deps = getDeps(file, src);
if (deps) fromDeps(file, src, pkg, fakePath, deps);

@@ -556,2 +583,9 @@ }

function toStream (dataAsString) {
var tr = through();
tr.push(dataAsString);
tr.push(null);
return tr;
}
function has (obj, key) {

@@ -558,0 +592,0 @@ return obj && Object.prototype.hasOwnProperty.call(obj, key);

{
"name": "module-deps",
"version": "4.0.8",
"version": "4.1.0",
"description": "walk the dependency graph to generate json output that can be fed into browser-pack",

@@ -5,0 +5,0 @@ "main": "index.js",

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc