/** Currently will not pipe down more items after count satisfied */ export function limits(n = 1, { terminate = false } = {}) { return new TransformStream({ transform: async (chunk, ctrl) => { if (n-- > 0) { ctrl.enqueue(chunk); return; } terminate && ctrl.terminate(); return new Promise(() => null); // will never return }, flush: () => {}, }); }