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
49 lines (41 loc) • 1.15 kB
text/typescript
// import { sleep } from "bun";
// import sflow from "./index";
// it("works number", async () => {
// const { value, readable } = await sflow([1, 2, 3])
// .forEach(async (e) => {
// await sleep(10);
// })
// .toLatest();
// readable.done();
// // wait for first emit
// await sleep(5);
// expect(await value).toEqual(1);
// // expect(await obj).toEqual(false);
// await sleep(10);
// expect(await value).toEqual(2);
// // expect(await obj).toEqual(false);
// await sleep(10);
// expect(await value).toEqual(3);
// // expect(await obj).toEqual(true);
// });
// it("works obj", async () => {
// const { value, readable } = await sflow([
// { a: 1 },
// { a: { b: { c: 2 } } },
// { a: 3 },
// ])
// .forEach(async () => {
// await sleep(10);
// })
// .toLatest();
// readable.done();
// // wait for first emit
// await sleep(5);
// expect(value).toEqual({ a: 1 });
// await sleep(10);
// // @ts-ignore
// expect(value.a.b.c).toEqual(2);
// expect(value).toEqual({ a: { b: { c: 2 } } });
// await sleep(10);
// expect(value).toEqual({ a: 3 });
// });