sflow
Version:
sflow is a powerful and highly-extensible library designed for processing and manipulating streams of data effortlessly. Inspired by the functional programming paradigm, it provides a rich set of utilities for transforming streams, including chunking, fil
42 lines (38 loc) • 747 B
text/typescript
import { sflow } from "./index";
import { sleep } from "./utils";
/* wip */
it("eager", () => {
sflow(
new ReadableStream({
start: (ctrl) => {
ctrl.enqueue(1);
ctrl.enqueue(2);
ctrl.enqueue(3);
ctrl.close();
},
}),
).pipeTo(new WritableStream({ write: (c) => console.log(c) }));
});
it.skip("passive", () => {
let i = 0;
sflow(
new ReadableStream({
pull: (ctrl) => {
console.log("pulling", i);
ctrl.enqueue(i++);
},
}),
).pipeTo(
new WritableStream(
{
start: (e) => {
e.signal;
},
write: async (_c, _ctrl) => {
await sleep(10);
},
},
{ highWaterMark: 2 },
),
);
});