Bläddra i källkod

Renamed fromIterable => readableFrom.

Eugene Lazutkin 3 år sedan
förälder
incheckning
ce7f4e3c23

+ 2 - 2
src/utils/fromIterable.js

@@ -3,7 +3,7 @@
 const {Readable} = require('stream');
 const defs = require('../defs');
 
-const fromIterable = options => {
+const readableFrom = options => {
   if (!options || !options.iterable) {
     options = {iterable: options};
   }
@@ -128,4 +128,4 @@ const fromIterable = options => {
   return stream;
 };
 
-module.exports = fromIterable;
+module.exports = readableFrom;

+ 3 - 3
tests/test-demo.mjs

@@ -4,7 +4,7 @@ import test from 'tape-six';
 
 import {Transform} from 'stream';
 import chain from '../src/index.js';
-import fromIterable from '../src/utils/fromIterable.js';
+import readableFrom from '../src/utils/readableFrom.js';
 
 const getTotalFromDatabaseByKey = async x =>
   new Promise(resolve => {
@@ -45,7 +45,7 @@ test.asPromise('demo: default', (t, resolve) => {
     resolve();
   });
 
-  fromIterable([1, 2, 3]).pipe(c);
+  readableFrom([1, 2, 3]).pipe(c);
 });
 
 test.asPromise('demo: no grouping', (t, resolve) => {
@@ -83,5 +83,5 @@ test.asPromise('demo: no grouping', (t, resolve) => {
     resolve();
   });
 
-  fromIterable([1, 2, 3]).pipe(c);
+  readableFrom([1, 2, 3]).pipe(c);
 });

+ 9 - 9
tests/test-fold.mjs

@@ -4,7 +4,7 @@ import test from 'tape-six';
 
 import {streamToArray, delay} from './helpers.mjs';
 import chain from '../src/index.js';
-import fromIterable from '../src/utils/fromIterable.js';
+import readableFrom from '../src/utils/readableFrom.js';
 
 import fold from '../src/utils/fold.js';
 import scan from '../src/utils/scan.js';
@@ -13,7 +13,7 @@ import reduceStream from '../src/utils/reduceStream.js';
 
 test.asPromise('fold: smoke test', (t, resolve) => {
   const output = [],
-    c = chain([fromIterable([1, 2, 3]), fold((acc, x) => acc + x, 0), streamToArray(output)]);
+    c = chain([readableFrom([1, 2, 3]), fold((acc, x) => acc + x, 0), streamToArray(output)]);
 
   c.on('end', () => {
     t.deepEqual(output, [6]);
@@ -24,7 +24,7 @@ test.asPromise('fold: smoke test', (t, resolve) => {
 test.asPromise('fold: async', (t, resolve) => {
   const output = [],
     c = chain([
-      fromIterable([1, 2, 3]),
+      readableFrom([1, 2, 3]),
       fold(
         delay((acc, x) => acc + x),
         0
@@ -40,7 +40,7 @@ test.asPromise('fold: async', (t, resolve) => {
 
 test.asPromise('fold: scan', (t, resolve) => {
   const output = [],
-    c = chain([fromIterable([1, 2, 3]), scan((acc, x) => acc + x, 0), streamToArray(output)]);
+    c = chain([readableFrom([1, 2, 3]), scan((acc, x) => acc + x, 0), streamToArray(output)]);
 
   c.on('end', () => {
     t.deepEqual(output, [1, 3, 6]);
@@ -51,7 +51,7 @@ test.asPromise('fold: scan', (t, resolve) => {
 test.asPromise('fold: scan async', (t, resolve) => {
   const output = [],
     c = chain([
-      fromIterable([1, 2, 3]),
+      readableFrom([1, 2, 3]),
       scan(
         delay((acc, x) => acc + x),
         0
@@ -67,7 +67,7 @@ test.asPromise('fold: scan async', (t, resolve) => {
 
 test.asPromise('fold: reduce', (t, resolve) => {
   const output = [],
-    c = chain([fromIterable([1, 2, 3]), fold((acc, x) => acc + x, 0), streamToArray(output)]);
+    c = chain([readableFrom([1, 2, 3]), fold((acc, x) => acc + x, 0), streamToArray(output)]);
 
   c.on('end', () => {
     t.deepEqual(output, [6]);
@@ -78,7 +78,7 @@ test.asPromise('fold: reduce', (t, resolve) => {
 test.asPromise('fold: reduce async', (t, resolve) => {
   const output = [],
     c = chain([
-      fromIterable([1, 2, 3]),
+      readableFrom([1, 2, 3]),
       reduce(
         delay((acc, x) => acc + x),
         0
@@ -95,7 +95,7 @@ test.asPromise('fold: reduce async', (t, resolve) => {
 test.asPromise('fold: reduce stream', (t, resolve) => {
   const r = reduceStream((acc, x) => acc + x, 0);
 
-  fromIterable([1, 2, 3]).pipe(r);
+  readableFrom([1, 2, 3]).pipe(r);
 
   r.on('finish', () => {
     t.deepEqual(r.accumulator, 6);
@@ -106,7 +106,7 @@ test.asPromise('fold: reduce stream', (t, resolve) => {
 test.asPromise('fold: reduce stream async', (t, resolve) => {
   const r = reduceStream({reducer: delay((acc, x) => acc + x), initial: 0});
 
-  fromIterable([1, 2, 3]).pipe(r);
+  readableFrom([1, 2, 3]).pipe(r);
 
   r.on('finish', () => {
     t.deepEqual(r.accumulator, 6);

+ 1 - 1
tests/test-fun.mjs

@@ -4,7 +4,7 @@ import test from 'tape-six';
 
 import {streamToArray, delay} from './helpers.mjs';
 import chain, {none, finalValue, many} from '../src/index.js';
-import fromIterable from '../src/utils/fromIterable.js';
+import fromIterable from '../src/utils/readableFrom.js';
 
 import fun from '../src/fun.js';
 

+ 1 - 1
tests/test-gen.mjs

@@ -4,7 +4,7 @@ import test from 'tape-six';
 
 import {streamToArray, delay} from './helpers.mjs';
 import chain, {none, finalValue, many, gen} from '../src/index.js';
-import fromIterable from '../src/utils/fromIterable.js';
+import fromIterable from '../src/utils/readableFrom.js';
 
 test.asPromise('gen: smoke test', (t, resolve) => {
   const output = [],

+ 1 - 1
tests/test-readWrite.mjs

@@ -4,7 +4,7 @@ import test from 'tape-six';
 
 import {streamToArray} from './helpers.mjs';
 import chain from '../src/index.js';
-import fromIterable from '../src/utils/fromIterable.js';
+import fromIterable from '../src/utils/readableFrom.js';
 
 test.asPromise('readWrite: readable', (t, resolve) => {
   const output1 = [],

+ 13 - 13
tests/test-fromIterable.mjs

@@ -5,11 +5,11 @@ import test from 'tape-six';
 import {streamToArray, delay} from './helpers.mjs';
 import chain from '../src/index.js';
 
-import fromIterable from '../src/utils/fromIterable.js';
+import readableFrom from '../src/utils/readableFrom.js';
 
-test.asPromise('fromIterable: smoke test', (t, resolve) => {
+test.asPromise('readableFrom: smoke test', (t, resolve) => {
   const output = [],
-    c = chain([fromIterable([1, 2, 3]), streamToArray(output)]);
+    c = chain([readableFrom([1, 2, 3]), streamToArray(output)]);
 
   c.on('end', () => {
     t.deepEqual(output, [1, 2, 3]);
@@ -17,9 +17,9 @@ test.asPromise('fromIterable: smoke test', (t, resolve) => {
   });
 });
 
-test.asPromise('fromIterable: function', (t, resolve) => {
+test.asPromise('readableFrom: function', (t, resolve) => {
   const output = [],
-    c = chain([fromIterable(() => 0), streamToArray(output)]);
+    c = chain([readableFrom(() => 0), streamToArray(output)]);
 
   c.on('end', () => {
     t.deepEqual(output, [0]);
@@ -27,9 +27,9 @@ test.asPromise('fromIterable: function', (t, resolve) => {
   });
 });
 
-test.asPromise('fromIterable: async function', (t, resolve) => {
+test.asPromise('readableFrom: async function', (t, resolve) => {
   const output = [],
-    c = chain([fromIterable(delay(() => 0)), streamToArray(output)]);
+    c = chain([readableFrom(delay(() => 0)), streamToArray(output)]);
 
   c.on('end', () => {
     t.deepEqual(output, [0]);
@@ -37,10 +37,10 @@ test.asPromise('fromIterable: async function', (t, resolve) => {
   });
 });
 
-test.asPromise('fromIterable: generator', (t, resolve) => {
+test.asPromise('readableFrom: generator', (t, resolve) => {
   const output = [],
     c = chain([
-      fromIterable(function* () {
+      readableFrom(function* () {
         yield 0;
         yield 1;
       }),
@@ -53,10 +53,10 @@ test.asPromise('fromIterable: generator', (t, resolve) => {
   });
 });
 
-test.asPromise('fromIterable: async generator', (t, resolve) => {
+test.asPromise('readableFrom: async generator', (t, resolve) => {
   const output = [],
     c = chain([
-      fromIterable(async function* () {
+      readableFrom(async function* () {
         yield delay(() => 0)();
         yield delay(() => 1)();
       }),
@@ -69,10 +69,10 @@ test.asPromise('fromIterable: async generator', (t, resolve) => {
   });
 });
 
-test.asPromise('fromIterable: nextable', (t, resolve) => {
+test.asPromise('readableFrom: nextable', (t, resolve) => {
   const output = [],
     c = chain([
-      fromIterable(
+      readableFrom(
         (function* () {
           yield 0;
           yield 1;

+ 1 - 1
tests/test-simple.mjs

@@ -5,7 +5,7 @@ import test from 'tape-six';
 import {Transform} from 'stream';
 import {streamToArray, delay} from './helpers.mjs';
 import chain from '../src/index.js';
-import fromIterable from '../src/utils/fromIterable.js';
+import fromIterable from '../src/utils/readableFrom.js';
 
 test.asPromise('simple: smoke test', (t, resolve) => {
   const c = chain([x => x * x]),

+ 1 - 1
tests/test-skip.mjs

@@ -4,7 +4,7 @@ import test from 'tape-six';
 
 import {streamToArray, delay} from './helpers.mjs';
 import chain from '../src/index.js';
-import fromIterable from '../src/utils/fromIterable.js';
+import fromIterable from '../src/utils/readableFrom.js';
 
 import skip from '../src/utils/skip.js';
 import skipWhile from '../src/utils/skipWhile.js';

+ 1 - 1
tests/test-take.mjs

@@ -4,7 +4,7 @@ import test from 'tape-six';
 
 import {streamToArray, delay} from './helpers.mjs';
 import chain, {stop} from '../src/index.js';
-import fromIterable from '../src/utils/fromIterable.js';
+import fromIterable from '../src/utils/readableFrom.js';
 
 import take from '../src/utils/take.js';
 import takeWhile from '../src/utils/takeWhile.js';

+ 1 - 1
tests/test-transducers.mjs

@@ -4,7 +4,7 @@ import test from 'tape-six';
 
 import {streamToArray} from './helpers.mjs';
 import chain, {gen} from '../src/index.js';
-import fromIterable from '../src/utils/fromIterable.js';
+import fromIterable from '../src/utils/readableFrom.js';
 
 test.asPromise('transducers: smoke test', (t, resolve) => {
   const output = [],