[Pkg-javascript-commits] [node-read-only-stream] 01/22: works
Bastien Roucariès
rouca at moszumanska.debian.org
Sun Aug 20 13:52:17 UTC 2017
This is an automated email from the git hooks/post-receive script.
rouca pushed a commit to branch master
in repository node-read-only-stream.
commit 88de622eaaa6c2fa1b9d50fb9d7f64e41daf19d8
Author: James Halliday <mail at substack.net>
Date: Mon Sep 8 11:03:26 2014 +0100
works
---
index.js | 24 ++++++++++++++++++++++++
1 file changed, 24 insertions(+)
diff --git a/index.js b/index.js
new file mode 100644
index 0000000..2537f7e
--- /dev/null
+++ b/index.js
@@ -0,0 +1,24 @@
+var Readable = require('readable-stream/readable');
+
+module.exports = function (stream) {
+ var ro = new Readable;
+ var waiting = false;
+
+ stream.on('readable', function () {
+ if (waiting) {
+ waiting = false;
+ ro._read();
+ }
+ });
+
+ ro._read = function () {
+ var buf, reads = 0;
+ while ((buf = stream.read()) !== null) {
+ ro.push(buf);
+ reads ++;
+ }
+ if (reads === 0) waiting = true;
+ };
+ stream.once('end', function () { ro.push(null) });
+ return ro;
+};
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/node-read-only-stream.git
More information about the Pkg-javascript-commits
mailing list