[Pkg-javascript-commits] [node-module-deps] 242/444: wrapper for streams1 transforms to prevent losing data

Bastien Roucariès rouca at moszumanska.debian.org
Fri Dec 15 09:47:59 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 303388c7375672c1b7b42602f8258e1ca38d95bb
Author: James Halliday <mail at substack.net>
Date:   Thu Jul 3 08:08:57 2014 -0700

    wrapper for streams1 transforms to prevent losing data
---
 index.js | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/index.js b/index.js
index 7c277aa..98957dc 100644
--- a/index.js
+++ b/index.js
@@ -208,12 +208,12 @@ Deps.prototype.getTransforms = function (file, pkg) {
         if (typeof tr === 'function') {
             var t = tr(file, trOpts);
             self.emit('transform', t, file);
-            nextTick(cb, null, t);
+            nextTick(cb, null, wrapTransform(t));
         }
         else {
             loadTransform(tr, trOpts, function (err, trs) {
                 if (err) return cb(err);
-                cb(null, trs);
+                cb(null, wrapTransform(trs));
             });
         }
     }
@@ -438,3 +438,10 @@ function xhas (obj) {
 function has (obj, key) {
     return Object.prototype.hasOwnProperty.call(obj, key);
 }
+
+function wrapTransform (tr) {
+    if (typeof tr.read === 'function') return tr;
+    var input = through(), output = through();
+    input.pipe(tr).pipe(output);
+    return duplexer(input, output);
+}

-- 
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