Browse Source

Small renames.

Eugene Lazutkin 7 năm trước cách đây
mục cha
commit
a9b42a7fe9
1 tập tin đã thay đổi với 8 bổ sung4 xóa
  1. 8 4
      index.js

+ 8 - 4
index.js

@@ -50,15 +50,19 @@ const wrapFunction = fn =>
     }
   });
 
-const wrapArray = array =>
+const wrapArray = fns =>
   new Transform({
     writableObjectMode: true,
     readableObjectMode: true,
     transform(chunk, encoding, callback) {
       try {
         let value = chunk;
-        for (let i = 0; i < array.length; ++i) {
-          const result = array[i].call(this, value, encoding);
+        for (let i = 0; i < fns.length; ++i) {
+          const result = fns[i].call(this, value, encoding);
+          if (result === Chain.none) {
+            callback(null);
+            return;
+          }
           if (result instanceof Chain.Final) {
             value = result.value;
             break;
@@ -163,7 +167,7 @@ class Chain extends Duplex {
   }
   static convertToTransform(fn) {
     if (typeof fn === 'function') return wrapFunction(fn);
-    if (fn instanceof Array) return fn.length ? wrapArray(fn) : 0;
+    if (fn instanceof Array) return fn.length ? wrapArray(fn) : null;
     return null;
   }
 }