|
|
@@ -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);
|