UNPKG

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

15 lines (13 loc) 452 B
export const tees: { <T>(fn: (s: ReadableStream<T>) => void | any): TransformStream<T, T>; <T>(stream?: WritableStream<T>): TransformStream<T, T>; } = (arg) => { if (!arg) return new TransformStream(); if (arg instanceof WritableStream) return tees((s) => s.pipeTo(arg)); const fn = arg; const { writable, readable } = new TransformStream(); const [a, b] = readable.tee(); // @ts-ignore fn(a); return { writable, readable: b }; };