[Pkg-javascript-commits] [node-module-deps] 85/444: object-form for opts.cache
Bastien Roucariès
rouca at moszumanska.debian.org
Fri Dec 15 09:47:45 UTC 2017
This is an automated email from the git hooks/post-receive script.
rouca pushed a commit to branch master
in repository node-module-deps.
commit a3935feb087842dd720610d4ffdc6c7fe4d8e284
Author: James Halliday <mail at substack.net>
Date: Thu May 30 06:41:05 2013 -0700
object-form for opts.cache
---
index.js | 16 ++++++++++++++--
readme.markdown | 3 +--
2 files changed, 15 insertions(+), 4 deletions(-)
diff --git a/index.js b/index.js
index f928d62..6ef5e40 100644
--- a/index.js
+++ b/index.js
@@ -53,7 +53,15 @@ module.exports = function (mains, opts) {
return pkg;
};
- resolve(id, parent, function (err, file) {
+ var resolver = opts.cache && typeof opts.cache[parent.id] === 'object'
+ && opts.cache[parent.id].deps[id]
+ ? function (xid, xparent, cb) {
+ cb(null, opts.cache[parent.id].deps[id]);
+ }
+ : resolve;
+ ;
+
+ resolver(id, parent, function (err, file) {
if (err) return output.emit('error', err);
if (!file) return output.emit('error', new Error([
'module not found: "' + id + '" from file ',
@@ -105,7 +113,11 @@ module.exports = function (mains, opts) {
function parseDeps (file, src) {
var deps;
- if (opts.noParse && opts.noParse.indexOf(file) >= 0) {
+ if (typeof src === 'object') {
+ deps = Object.keys(src.deps);
+ src = src.source;
+ }
+ else if (opts.noParse && opts.noParse.indexOf(file) >= 0) {
deps = [];
}
else if (/\.json$/.test(file)) {
diff --git a/readme.markdown b/readme.markdown
index 765f144..8713ce1 100644
--- a/readme.markdown
+++ b/readme.markdown
@@ -81,8 +81,7 @@ the values. `opts.packageFilter(pkg)` should return the new `pkg` object to use.
* opts.noParse - an array of absolute paths to not parse for dependencies. Use
this for large dependencies like jquery or threejs which take forever to parse.
-* opts.cache - an object mapping filenames to strings of file contents to skip
-doing fs.readFile() calls
+* opts.cache - an object mapping filenames to file objects to skip costly io
# transforms
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/node-module-deps.git
More information about the Pkg-javascript-commits
mailing list