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

9 lines (8 loc) 219 B
import { never } from "./never"; export function heads<T>(n = 1) { return new TransformStream<T, T>({ transform: async (chunk, ctrl) => { return n-- > 0 ? ctrl.enqueue(chunk) : await never(); }, }); }