[Pkg-javascript-commits] [node-module-deps] 18/444: using through
Bastien Roucariès
rouca at moszumanska.debian.org
Fri Dec 15 09:47:39 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 c35890740157a0a320f6d34ef6b102deb27dfb2e
Author: James Halliday <mail at substack.net>
Date: Thu Feb 21 01:52:57 2013 -0800
using through
---
index.js | 15 ++++++++-------
1 file changed, 8 insertions(+), 7 deletions(-)
diff --git a/index.js b/index.js
index ac17a79..a846001 100644
--- a/index.js
+++ b/index.js
@@ -2,7 +2,7 @@ var fs = require('fs');
var path = require('path');
var required = require('required');
-var Stream = require('stream');
+var through = require('through');
module.exports = function (mains, opts) {
if (!Array.isArray(mains)) mains = [ mains ].filter(Boolean);
@@ -14,8 +14,7 @@ module.exports = function (mains, opts) {
var cache = {};
var pending = 0;
- var output = new Stream;
- output.readable = true;
+ var output = through();
if (!opts) opts = {};
if (opts.cache === undefined) opts.cache = cache;
@@ -36,11 +35,11 @@ module.exports = function (mains, opts) {
return acc;
}, {})
};
- output.emit('data', files[file]);
+ output.queue(files[file]);
};
walk(rows);
- if (--pending === 0) output.emit('end');
+ if (--pending === 0) output.queue(null);
}
fs.readFile(file, 'utf8', function (err, s) {
@@ -56,7 +55,9 @@ module.exports = function (mains, opts) {
});
});
- if (pending === 0) process.nextTick(output.emit.bind(output, 'end'));
+ if (pending === 0) process.nextTick(function () {
+ output.queue(null);
+ });
return output;
@@ -74,7 +75,7 @@ module.exports = function (mains, opts) {
if (mains.indexOf(row.filename) >= 0) {
r.entry = true;
}
- output.emit('data', r);
+ output.queue(r);
walk(row.deps || []);
});
--
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