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

14 lines (13 loc) 311 B
export function riffles<T>(sep: T): TransformStream<T, T> { let last: T; return new TransformStream({ transform: (chunk, ctrl) => { if (undefined !== last) { ctrl.enqueue(last); ctrl.enqueue(sep); } last = chunk; }, flush: (ctrl) => ctrl.enqueue(last), }); }