Update tests make export a bit nicer
This commit is contained in:
parent
1675b18d5b
commit
74ce415118
@ -28,7 +28,7 @@ import { unbatch } from "./unbatch";
|
|||||||
import { compose } from "./compose";
|
import { compose } from "./compose";
|
||||||
import { demux } from "./demux";
|
import { demux } from "./demux";
|
||||||
|
|
||||||
export default function strom(defaultOptions?: TransformOptions) {
|
export function strom(defaultOptions?: TransformOptions) {
|
||||||
function withDefaultOptions<T extends any[], R>(
|
function withDefaultOptions<T extends any[], R>(
|
||||||
n: number,
|
n: number,
|
||||||
fn: (...args: T) => R,
|
fn: (...args: T) => R,
|
||||||
|
@ -1,6 +1,2 @@
|
|||||||
import mhysa from "./functions";
|
export { strom } from "./functions";
|
||||||
import * as _utils from "./utils";
|
export * from "./utils";
|
||||||
export default mhysa;
|
|
||||||
|
|
||||||
// @TODO fix this with proper import export
|
|
||||||
export const utils = { ..._utils };
|
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
import test from "ava";
|
import test from "ava";
|
||||||
import { expect } from "chai";
|
import { expect } from "chai";
|
||||||
import { Readable } from "stream";
|
import { Readable } from "stream";
|
||||||
import mhysa from "../src";
|
import { strom } from "../src";
|
||||||
import { FlushStrategy } from "../src/functions/accumulator";
|
import { FlushStrategy } from "../src/functions/accumulator";
|
||||||
import { performance } from "perf_hooks";
|
import { performance } from "perf_hooks";
|
||||||
const { accumulator, accumulatorBy } = mhysa({ objectMode: true });
|
const { accumulator, accumulatorBy } = strom({ objectMode: true });
|
||||||
|
|
||||||
test.cb("accumulator() rolling", t => {
|
test.cb("accumulator() rolling", t => {
|
||||||
t.plan(3);
|
t.plan(3);
|
||||||
@ -14,8 +14,14 @@ test.cb("accumulator() rolling", t => {
|
|||||||
key: string;
|
key: string;
|
||||||
}
|
}
|
||||||
const source = new Readable({ objectMode: true });
|
const source = new Readable({ objectMode: true });
|
||||||
const firstFlush = [{ ts: 0, key: "a" }, { ts: 1, key: "b" }];
|
const firstFlush = [
|
||||||
const secondFlush = [{ ts: 2, key: "d" }, { ts: 3, key: "e" }];
|
{ ts: 0, key: "a" },
|
||||||
|
{ ts: 1, key: "b" },
|
||||||
|
];
|
||||||
|
const secondFlush = [
|
||||||
|
{ ts: 2, key: "d" },
|
||||||
|
{ ts: 3, key: "e" },
|
||||||
|
];
|
||||||
const thirdFlush = [{ ts: 4, key: "f" }];
|
const thirdFlush = [{ ts: 4, key: "f" }];
|
||||||
const flushes = [firstFlush, secondFlush, thirdFlush];
|
const flushes = [firstFlush, secondFlush, thirdFlush];
|
||||||
|
|
||||||
@ -88,7 +94,10 @@ test.cb(
|
|||||||
"nonExistingKey",
|
"nonExistingKey",
|
||||||
{ objectMode: true },
|
{ objectMode: true },
|
||||||
);
|
);
|
||||||
const input = [{ ts: 0, key: "a" }, { ts: 1, key: "b" }];
|
const input = [
|
||||||
|
{ ts: 0, key: "a" },
|
||||||
|
{ ts: 1, key: "b" },
|
||||||
|
];
|
||||||
|
|
||||||
source
|
source
|
||||||
.pipe(accumulatorStream)
|
.pipe(accumulatorStream)
|
||||||
@ -182,7 +191,10 @@ test.cb("accumulator() sliding", t => {
|
|||||||
{ ts: 4, key: "d" },
|
{ ts: 4, key: "d" },
|
||||||
];
|
];
|
||||||
const firstFlush = [{ ts: 0, key: "a" }];
|
const firstFlush = [{ ts: 0, key: "a" }];
|
||||||
const secondFlush = [{ ts: 0, key: "a" }, { ts: 1, key: "b" }];
|
const secondFlush = [
|
||||||
|
{ ts: 0, key: "a" },
|
||||||
|
{ ts: 1, key: "b" },
|
||||||
|
];
|
||||||
const thirdFlush = [
|
const thirdFlush = [
|
||||||
{ ts: 0, key: "a" },
|
{ ts: 0, key: "a" },
|
||||||
{ ts: 1, key: "b" },
|
{ ts: 1, key: "b" },
|
||||||
@ -232,7 +244,10 @@ test.cb("accumulator() sliding with key", t => {
|
|||||||
{ ts: 6, key: "g" },
|
{ ts: 6, key: "g" },
|
||||||
];
|
];
|
||||||
const firstFlush = [{ ts: 0, key: "a" }];
|
const firstFlush = [{ ts: 0, key: "a" }];
|
||||||
const secondFlush = [{ ts: 0, key: "a" }, { ts: 1, key: "b" }];
|
const secondFlush = [
|
||||||
|
{ ts: 0, key: "a" },
|
||||||
|
{ ts: 1, key: "b" },
|
||||||
|
];
|
||||||
const thirdFlush = [
|
const thirdFlush = [
|
||||||
{ ts: 0, key: "a" },
|
{ ts: 0, key: "a" },
|
||||||
{ ts: 1, key: "b" },
|
{ ts: 1, key: "b" },
|
||||||
@ -243,8 +258,14 @@ test.cb("accumulator() sliding with key", t => {
|
|||||||
{ ts: 2, key: "c" },
|
{ ts: 2, key: "c" },
|
||||||
{ ts: 3, key: "d" },
|
{ ts: 3, key: "d" },
|
||||||
];
|
];
|
||||||
const fifthFlush = [{ ts: 3, key: "d" }, { ts: 5, key: "f" }];
|
const fifthFlush = [
|
||||||
const sixthFlush = [{ ts: 5, key: "f" }, { ts: 6, key: "g" }];
|
{ ts: 3, key: "d" },
|
||||||
|
{ ts: 5, key: "f" },
|
||||||
|
];
|
||||||
|
const sixthFlush = [
|
||||||
|
{ ts: 5, key: "f" },
|
||||||
|
{ ts: 6, key: "g" },
|
||||||
|
];
|
||||||
|
|
||||||
const flushes = [
|
const flushes = [
|
||||||
firstFlush,
|
firstFlush,
|
||||||
@ -286,7 +307,10 @@ test.cb(
|
|||||||
"nonExistingKey",
|
"nonExistingKey",
|
||||||
{ objectMode: true },
|
{ objectMode: true },
|
||||||
);
|
);
|
||||||
const input = [{ ts: 0, key: "a" }, { ts: 1, key: "b" }];
|
const input = [
|
||||||
|
{ ts: 0, key: "a" },
|
||||||
|
{ ts: 1, key: "b" },
|
||||||
|
];
|
||||||
|
|
||||||
source
|
source
|
||||||
.pipe(accumulatorStream)
|
.pipe(accumulatorStream)
|
||||||
@ -334,10 +358,22 @@ test.cb(
|
|||||||
{ ts: 6, key: "g" },
|
{ ts: 6, key: "g" },
|
||||||
];
|
];
|
||||||
const firstFlush = [{ ts: 0, key: "a" }];
|
const firstFlush = [{ ts: 0, key: "a" }];
|
||||||
const secondFlush = [{ ts: 0, key: "a" }, { ts: 2, key: "c" }];
|
const secondFlush = [
|
||||||
const thirdFlush = [{ ts: 2, key: "c" }, { ts: 3, key: "d" }];
|
{ ts: 0, key: "a" },
|
||||||
const fourthFlush = [{ ts: 3, key: "d" }, { ts: 5, key: "f" }];
|
{ ts: 2, key: "c" },
|
||||||
const fifthFlush = [{ ts: 5, key: "f" }, { ts: 6, key: "g" }];
|
];
|
||||||
|
const thirdFlush = [
|
||||||
|
{ ts: 2, key: "c" },
|
||||||
|
{ ts: 3, key: "d" },
|
||||||
|
];
|
||||||
|
const fourthFlush = [
|
||||||
|
{ ts: 3, key: "d" },
|
||||||
|
{ ts: 5, key: "f" },
|
||||||
|
];
|
||||||
|
const fifthFlush = [
|
||||||
|
{ ts: 5, key: "f" },
|
||||||
|
{ ts: 6, key: "g" },
|
||||||
|
];
|
||||||
|
|
||||||
const flushes = [
|
const flushes = [
|
||||||
firstFlush,
|
firstFlush,
|
||||||
@ -469,7 +505,10 @@ test.cb("accumulatorBy() sliding", t => {
|
|||||||
{ ts: 6, key: "g" },
|
{ ts: 6, key: "g" },
|
||||||
];
|
];
|
||||||
const firstFlush = [{ ts: 0, key: "a" }];
|
const firstFlush = [{ ts: 0, key: "a" }];
|
||||||
const secondFlush = [{ ts: 0, key: "a" }, { ts: 1, key: "b" }];
|
const secondFlush = [
|
||||||
|
{ ts: 0, key: "a" },
|
||||||
|
{ ts: 1, key: "b" },
|
||||||
|
];
|
||||||
const thirdFlush = [
|
const thirdFlush = [
|
||||||
{ ts: 0, key: "a" },
|
{ ts: 0, key: "a" },
|
||||||
{ ts: 1, key: "b" },
|
{ ts: 1, key: "b" },
|
||||||
@ -480,8 +519,14 @@ test.cb("accumulatorBy() sliding", t => {
|
|||||||
{ ts: 2, key: "c" },
|
{ ts: 2, key: "c" },
|
||||||
{ ts: 3, key: "d" },
|
{ ts: 3, key: "d" },
|
||||||
];
|
];
|
||||||
const fifthFlush = [{ ts: 3, key: "d" }, { ts: 5, key: "f" }];
|
const fifthFlush = [
|
||||||
const sixthFlush = [{ ts: 5, key: "f" }, { ts: 6, key: "g" }];
|
{ ts: 3, key: "d" },
|
||||||
|
{ ts: 5, key: "f" },
|
||||||
|
];
|
||||||
|
const sixthFlush = [
|
||||||
|
{ ts: 5, key: "f" },
|
||||||
|
{ ts: 6, key: "g" },
|
||||||
|
];
|
||||||
|
|
||||||
const flushes = [
|
const flushes = [
|
||||||
firstFlush,
|
firstFlush,
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
import { Readable } from "stream";
|
import { Readable } from "stream";
|
||||||
import test from "ava";
|
import test from "ava";
|
||||||
import { expect } from "chai";
|
import { expect } from "chai";
|
||||||
import mhysa from "../src";
|
import { strom } from "../src";
|
||||||
const { batch, map, fromArray } = mhysa({ objectMode: true });
|
const { batch, map, fromArray } = strom({ objectMode: true });
|
||||||
|
|
||||||
test.cb("batch() batches chunks together", t => {
|
test.cb("batch() batches chunks together", t => {
|
||||||
t.plan(3);
|
t.plan(3);
|
||||||
|
@ -2,8 +2,8 @@ import * as cp from "child_process";
|
|||||||
import { Readable } from "stream";
|
import { Readable } from "stream";
|
||||||
import test from "ava";
|
import test from "ava";
|
||||||
import { expect } from "chai";
|
import { expect } from "chai";
|
||||||
import mhysa from "../src";
|
import { strom } from "../src";
|
||||||
const { child } = mhysa();
|
const { child } = strom();
|
||||||
|
|
||||||
test.cb(
|
test.cb(
|
||||||
"child() allows easily writing to child process stdin and reading from its stdout",
|
"child() allows easily writing to child process stdin and reading from its stdout",
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
import { Readable } from "stream";
|
import { Readable } from "stream";
|
||||||
import test from "ava";
|
import test from "ava";
|
||||||
import { expect } from "chai";
|
import { expect } from "chai";
|
||||||
import mhysa from "../src";
|
import { strom } from "../src";
|
||||||
const { collect } = mhysa();
|
const { collect } = strom();
|
||||||
|
|
||||||
test.cb(
|
test.cb(
|
||||||
"collect() collects streamed elements into an array (object, flowing mode)",
|
"collect() collects streamed elements into an array (object, flowing mode)",
|
||||||
|
@ -2,9 +2,9 @@ import * as test from "ava";
|
|||||||
import { expect } from "chai";
|
import { expect } from "chai";
|
||||||
import { sleep } from "../src/helpers";
|
import { sleep } from "../src/helpers";
|
||||||
import { Readable, Writable } from "stream";
|
import { Readable, Writable } from "stream";
|
||||||
import mhysa from "../src";
|
import { strom } from "../src";
|
||||||
import { performance } from "perf_hooks";
|
import { performance } from "perf_hooks";
|
||||||
const { compose, map, fromArray } = mhysa({ objectMode: true });
|
const { compose, map, fromArray } = strom({ objectMode: true });
|
||||||
|
|
||||||
test.cb("compose() chains two streams together in the correct order", t => {
|
test.cb("compose() chains two streams together in the correct order", t => {
|
||||||
t.plan(3);
|
t.plan(3);
|
||||||
@ -114,13 +114,9 @@ test("compose() writable length should be less than highWaterMark when handing w
|
|||||||
return chunk;
|
return chunk;
|
||||||
});
|
});
|
||||||
|
|
||||||
const composed = compose(
|
const composed = compose([first, second], undefined, {
|
||||||
[first, second],
|
|
||||||
undefined,
|
|
||||||
{
|
|
||||||
highWaterMark: 2,
|
highWaterMark: 2,
|
||||||
},
|
});
|
||||||
);
|
|
||||||
composed.on("error", err => {
|
composed.on("error", err => {
|
||||||
reject();
|
reject();
|
||||||
});
|
});
|
||||||
@ -168,13 +164,9 @@ test("compose() should emit drain event ~rate * highWaterMark ms for every write
|
|||||||
return chunk;
|
return chunk;
|
||||||
});
|
});
|
||||||
|
|
||||||
const composed = compose(
|
const composed = compose([first, second], undefined, {
|
||||||
[first, second],
|
|
||||||
undefined,
|
|
||||||
{
|
|
||||||
highWaterMark,
|
highWaterMark,
|
||||||
},
|
});
|
||||||
);
|
|
||||||
composed.on("error", err => {
|
composed.on("error", err => {
|
||||||
reject();
|
reject();
|
||||||
});
|
});
|
||||||
@ -221,13 +213,9 @@ test.cb(
|
|||||||
return chunk;
|
return chunk;
|
||||||
});
|
});
|
||||||
|
|
||||||
const composed = compose(
|
const composed = compose([first, second], undefined, {
|
||||||
[first, second],
|
|
||||||
undefined,
|
|
||||||
{
|
|
||||||
highWaterMark: 5,
|
highWaterMark: 5,
|
||||||
},
|
});
|
||||||
);
|
|
||||||
|
|
||||||
composed.on("error", err => {
|
composed.on("error", err => {
|
||||||
t.end(err);
|
t.end(err);
|
||||||
@ -284,13 +272,9 @@ test.cb(
|
|||||||
{ highWaterMark: 1 },
|
{ highWaterMark: 1 },
|
||||||
);
|
);
|
||||||
|
|
||||||
const composed = compose(
|
const composed = compose([first, second], undefined, {
|
||||||
[first, second],
|
|
||||||
undefined,
|
|
||||||
{
|
|
||||||
highWaterMark: 5,
|
highWaterMark: 5,
|
||||||
},
|
});
|
||||||
);
|
|
||||||
composed.on("error", err => {
|
composed.on("error", err => {
|
||||||
t.end(err);
|
t.end(err);
|
||||||
});
|
});
|
||||||
@ -355,13 +339,9 @@ test.cb(
|
|||||||
{ highWaterMark: 2 },
|
{ highWaterMark: 2 },
|
||||||
);
|
);
|
||||||
|
|
||||||
const composed = compose(
|
const composed = compose([first, second], undefined, {
|
||||||
[first, second],
|
|
||||||
undefined,
|
|
||||||
{
|
|
||||||
highWaterMark: 5,
|
highWaterMark: 5,
|
||||||
},
|
});
|
||||||
);
|
|
||||||
composed.on("error", err => {
|
composed.on("error", err => {
|
||||||
t.end(err);
|
t.end(err);
|
||||||
});
|
});
|
||||||
@ -414,13 +394,9 @@ test.cb(
|
|||||||
return chunk;
|
return chunk;
|
||||||
});
|
});
|
||||||
|
|
||||||
const composed = compose(
|
const composed = compose([first, second], undefined, {
|
||||||
[first, second],
|
|
||||||
undefined,
|
|
||||||
{
|
|
||||||
highWaterMark: 6,
|
highWaterMark: 6,
|
||||||
},
|
});
|
||||||
);
|
|
||||||
|
|
||||||
composed.on("error", err => {
|
composed.on("error", err => {
|
||||||
t.end(err);
|
t.end(err);
|
||||||
@ -470,12 +446,9 @@ test.cb("compose() should be 'destroyable'", t => {
|
|||||||
return chunk;
|
return chunk;
|
||||||
});
|
});
|
||||||
|
|
||||||
const composed = compose(
|
const composed = compose([first, second], (err: any) => {
|
||||||
[first, second],
|
|
||||||
(err: any) => {
|
|
||||||
t.pass();
|
t.pass();
|
||||||
},
|
});
|
||||||
);
|
|
||||||
|
|
||||||
const fakeSource = new Readable({
|
const fakeSource = new Readable({
|
||||||
objectMode: true,
|
objectMode: true,
|
||||||
@ -531,13 +504,9 @@ test.cb("compose() `finish` and `end` propagates", t => {
|
|||||||
return chunk;
|
return chunk;
|
||||||
});
|
});
|
||||||
|
|
||||||
const composed = compose(
|
const composed = compose([first, second], undefined, {
|
||||||
[first, second],
|
|
||||||
undefined,
|
|
||||||
{
|
|
||||||
highWaterMark: 3,
|
highWaterMark: 3,
|
||||||
},
|
});
|
||||||
);
|
|
||||||
|
|
||||||
const fakeSource = new Readable({
|
const fakeSource = new Readable({
|
||||||
objectMode: true,
|
objectMode: true,
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
import { Readable } from "stream";
|
import { Readable } from "stream";
|
||||||
import test from "ava";
|
import test from "ava";
|
||||||
import { expect } from "chai";
|
import { expect } from "chai";
|
||||||
import mhysa from "../src";
|
import { strom } from "../src";
|
||||||
const { concat, collect } = mhysa();
|
const { concat, collect } = strom();
|
||||||
|
|
||||||
test.cb(
|
test.cb(
|
||||||
"concat() concatenates multiple readable streams (object, flowing mode)",
|
"concat() concatenates multiple readable streams (object, flowing mode)",
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
import { Readable } from "stream";
|
import { Readable } from "stream";
|
||||||
import test from "ava";
|
import test from "ava";
|
||||||
import mhysa from "../src";
|
import { strom } from "../src";
|
||||||
|
|
||||||
const withDefaultOptions = mhysa({ objectMode: true });
|
const withDefaultOptions = strom({ objectMode: true });
|
||||||
const withoutOptions = mhysa();
|
const withoutOptions = strom();
|
||||||
|
|
||||||
test("Mhysa instances can have default options", t => {
|
test("strom instances can have default options", t => {
|
||||||
let batch = withDefaultOptions.batch();
|
let batch = withDefaultOptions.batch();
|
||||||
t.true(batch._readableState.objectMode);
|
t.true(batch._readableState.objectMode);
|
||||||
t.true(batch._writableState.objectMode);
|
t.true(batch._writableState.objectMode);
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
import test from "ava";
|
import test from "ava";
|
||||||
import { expect } from "chai";
|
import { expect } from "chai";
|
||||||
import mhysa from "../src";
|
import { strom } from "../src";
|
||||||
import { Writable, Readable } from "stream";
|
import { Writable, Readable } from "stream";
|
||||||
const sinon = require("sinon");
|
import * as sinon from "sinon";
|
||||||
const { sleep } = require("../src/helpers");
|
import { sleep } from "../src/helpers";
|
||||||
import { performance } from "perf_hooks";
|
import { performance } from "perf_hooks";
|
||||||
const { demux, map, fromArray } = mhysa({ objectMode: true });
|
const { demux, map, fromArray } = strom({ objectMode: true });
|
||||||
|
|
||||||
interface Test {
|
interface Test {
|
||||||
key: string;
|
key: string;
|
||||||
|
@ -2,8 +2,8 @@ import * as cp from "child_process";
|
|||||||
import { Readable } from "stream";
|
import { Readable } from "stream";
|
||||||
import test from "ava";
|
import test from "ava";
|
||||||
import { expect } from "chai";
|
import { expect } from "chai";
|
||||||
import mhysa from "../src";
|
import { strom } from "../src";
|
||||||
const { duplex } = mhysa();
|
const { duplex } = strom();
|
||||||
|
|
||||||
test.cb(
|
test.cb(
|
||||||
"duplex() combines a writable and readable stream into a ReadWrite stream",
|
"duplex() combines a writable and readable stream into a ReadWrite stream",
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
import test from "ava";
|
import test from "ava";
|
||||||
import { expect } from "chai";
|
import { expect } from "chai";
|
||||||
import { Readable } from "stream";
|
import { Readable } from "stream";
|
||||||
import mhysa from "../src";
|
import { strom } from "../src";
|
||||||
const { filter } = mhysa();
|
const { filter } = strom();
|
||||||
|
|
||||||
test.cb("filter() filters elements synchronously", t => {
|
test.cb("filter() filters elements synchronously", t => {
|
||||||
t.plan(2);
|
t.plan(2);
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
import { Readable } from "stream";
|
import { Readable } from "stream";
|
||||||
import test from "ava";
|
import test from "ava";
|
||||||
import { expect } from "chai";
|
import { expect } from "chai";
|
||||||
import mhysa from "../src";
|
import { strom } from "../src";
|
||||||
const { flatMap } = mhysa({ objectMode: true });
|
const { flatMap } = strom({ objectMode: true });
|
||||||
|
|
||||||
test.cb("flatMap() maps elements synchronously", t => {
|
test.cb("flatMap() maps elements synchronously", t => {
|
||||||
t.plan(6);
|
t.plan(6);
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import test from "ava";
|
import test from "ava";
|
||||||
import { expect } from "chai";
|
import { expect } from "chai";
|
||||||
import mhysa from "../src";
|
import { strom } from "../src";
|
||||||
const { fromArray } = mhysa();
|
const { fromArray } = strom();
|
||||||
|
|
||||||
test.cb("fromArray() streams array elements in flowing mode", t => {
|
test.cb("fromArray() streams array elements in flowing mode", t => {
|
||||||
t.plan(3);
|
t.plan(3);
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
import { Readable } from "stream";
|
import { Readable } from "stream";
|
||||||
import test from "ava";
|
import test from "ava";
|
||||||
import { expect } from "chai";
|
import { expect } from "chai";
|
||||||
import mhysa from "../src";
|
import { strom } from "../src";
|
||||||
const { join } = mhysa();
|
const { join } = strom();
|
||||||
|
|
||||||
test.cb("join() joins chunks using the specified separator", t => {
|
test.cb("join() joins chunks using the specified separator", t => {
|
||||||
t.plan(9);
|
t.plan(9);
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
import { Readable } from "stream";
|
import { Readable } from "stream";
|
||||||
import test from "ava";
|
import test from "ava";
|
||||||
import { expect } from "chai";
|
import { expect } from "chai";
|
||||||
import mhysa from "../src";
|
import { strom } from "../src";
|
||||||
const { last } = mhysa();
|
const { last } = strom();
|
||||||
|
|
||||||
test("last() resolves to the last chunk streamed by the given readable stream", async t => {
|
test("last() resolves to the last chunk streamed by the given readable stream", async t => {
|
||||||
const source = new Readable({ objectMode: true });
|
const source = new Readable({ objectMode: true });
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
import { Readable } from "stream";
|
import { Readable } from "stream";
|
||||||
import test from "ava";
|
import test from "ava";
|
||||||
import { expect } from "chai";
|
import { expect } from "chai";
|
||||||
import mhysa from "../src";
|
import { strom } from "../src";
|
||||||
const { map } = mhysa();
|
const { map } = strom();
|
||||||
|
|
||||||
test.cb("map() maps elements synchronously", t => {
|
test.cb("map() maps elements synchronously", t => {
|
||||||
t.plan(3);
|
t.plan(3);
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
import { Readable } from "stream";
|
import { Readable } from "stream";
|
||||||
import test from "ava";
|
import test from "ava";
|
||||||
import { expect } from "chai";
|
import { expect } from "chai";
|
||||||
import mhysa from "../src";
|
import { strom } from "../src";
|
||||||
const { merge } = mhysa();
|
const { merge } = strom();
|
||||||
|
|
||||||
test.cb(
|
test.cb(
|
||||||
"merge() merges multiple readable streams in chunk arrival order",
|
"merge() merges multiple readable streams in chunk arrival order",
|
||||||
|
@ -2,9 +2,9 @@ import { Readable } from "stream";
|
|||||||
import { performance } from "perf_hooks";
|
import { performance } from "perf_hooks";
|
||||||
import test from "ava";
|
import test from "ava";
|
||||||
import { expect } from "chai";
|
import { expect } from "chai";
|
||||||
import mhysa from "../src";
|
import { strom } from "../src";
|
||||||
import { sleep } from "../src/helpers";
|
import { sleep } from "../src/helpers";
|
||||||
const { parallelMap } = mhysa({ objectMode: true });
|
const { parallelMap } = strom({ objectMode: true });
|
||||||
|
|
||||||
test.cb("parallelMap() parallel mapping", t => {
|
test.cb("parallelMap() parallel mapping", t => {
|
||||||
t.plan(6);
|
t.plan(6);
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
import { Readable, finished } from "stream";
|
import { Readable, finished } from "stream";
|
||||||
import test from "ava";
|
import test from "ava";
|
||||||
import { expect } from "chai";
|
import { expect } from "chai";
|
||||||
import mhysa from "../src";
|
import { strom } from "../src";
|
||||||
const { parse } = mhysa();
|
const { parse } = strom();
|
||||||
|
|
||||||
test.cb("parse() parses the streamed elements as JSON", t => {
|
test.cb("parse() parses the streamed elements as JSON", t => {
|
||||||
t.plan(3);
|
t.plan(3);
|
||||||
|
@ -2,8 +2,8 @@ import { Readable } from "stream";
|
|||||||
import { performance } from "perf_hooks";
|
import { performance } from "perf_hooks";
|
||||||
import test from "ava";
|
import test from "ava";
|
||||||
import { expect } from "chai";
|
import { expect } from "chai";
|
||||||
import mhysa from "../src";
|
import { strom } from "../src";
|
||||||
const { rate } = mhysa({ objectMode: true });
|
const { rate } = strom({ objectMode: true });
|
||||||
|
|
||||||
test.cb("rate() sends data at a rate of 150", t => {
|
test.cb("rate() sends data at a rate of 150", t => {
|
||||||
t.plan(5);
|
t.plan(5);
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
import { Readable } from "stream";
|
import { Readable } from "stream";
|
||||||
import test from "ava";
|
import test from "ava";
|
||||||
import { expect } from "chai";
|
import { expect } from "chai";
|
||||||
import mhysa from "../src";
|
import { strom } from "../src";
|
||||||
const { reduce } = mhysa({ objectMode: true });
|
const { reduce } = strom({ objectMode: true });
|
||||||
|
|
||||||
test.cb("reduce() reduces elements synchronously", t => {
|
test.cb("reduce() reduces elements synchronously", t => {
|
||||||
t.plan(1);
|
t.plan(1);
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
import { Readable } from "stream";
|
import { Readable } from "stream";
|
||||||
import test from "ava";
|
import test from "ava";
|
||||||
import { expect } from "chai";
|
import { expect } from "chai";
|
||||||
import mhysa from "../src";
|
import { strom } from "../src";
|
||||||
const { replace } = mhysa();
|
const { replace } = strom();
|
||||||
|
|
||||||
test.cb(
|
test.cb(
|
||||||
"replace() replaces occurrences of the given string in the streamed elements with the specified " +
|
"replace() replaces occurrences of the given string in the streamed elements with the specified " +
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
import { Readable } from "stream";
|
import { Readable } from "stream";
|
||||||
import test from "ava";
|
import test from "ava";
|
||||||
import { expect } from "chai";
|
import { expect } from "chai";
|
||||||
import mhysa from "../src";
|
import { strom } from "../src";
|
||||||
const { split } = mhysa();
|
const { split } = strom();
|
||||||
|
|
||||||
test.cb("split() splits chunks using the default separator (\\n)", t => {
|
test.cb("split() splits chunks using the default separator (\\n)", t => {
|
||||||
t.plan(5);
|
t.plan(5);
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
import { Readable } from "stream";
|
import { Readable } from "stream";
|
||||||
import test from "ava";
|
import test from "ava";
|
||||||
import { expect } from "chai";
|
import { expect } from "chai";
|
||||||
import mhysa from "../src";
|
import { strom } from "../src";
|
||||||
const { stringify } = mhysa();
|
const { stringify } = strom();
|
||||||
|
|
||||||
test.cb("stringify() stringifies the streamed elements as JSON", t => {
|
test.cb("stringify() stringifies the streamed elements as JSON", t => {
|
||||||
t.plan(4);
|
t.plan(4);
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
import { Readable } from "stream";
|
import { Readable } from "stream";
|
||||||
import test from "ava";
|
import test from "ava";
|
||||||
import { expect } from "chai";
|
import { expect } from "chai";
|
||||||
import mhysa from "../src";
|
import { strom } from "../src";
|
||||||
const { unbatch, batch } = mhysa({ objectMode: true });
|
const { unbatch, batch } = strom({ objectMode: true });
|
||||||
|
|
||||||
test.cb("unbatch() unbatches", t => {
|
test.cb("unbatch() unbatches", t => {
|
||||||
t.plan(3);
|
t.plan(3);
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import test from "ava";
|
import test from "ava";
|
||||||
import { collected } from "../../src/utils";
|
import { collected } from "../../src/utils";
|
||||||
import mhysa from "../../src";
|
import { strom } from "../../src";
|
||||||
const { fromArray, collect } = mhysa({ objectMode: true });
|
const { fromArray, collect } = strom({ objectMode: true });
|
||||||
|
|
||||||
test("collected returns a promise for the first data point", async t => {
|
test("collected returns a promise for the first data point", async t => {
|
||||||
const data = collected(fromArray([1, 2, 3, 4]).pipe(collect()));
|
const data = collected(fromArray([1, 2, 3, 4]).pipe(collect()));
|
||||||
|
Loading…
Reference in New Issue
Block a user