Stream element type
ReadableStream to consume
Promise resolving to the number of chunks read
const stream = createDataStream();
const count = await devnull(stream);
console.log(`Stream produced ${count} chunks`);
// Useful for benchmarking stream production
const start = Date.now();
const chunks = await devnull(dataGenerator());
console.log(`Generated ${chunks} chunks in ${Date.now() - start}ms`);
Consumes a ReadableStream without processing, counting the number of chunks.
Reads and discards all chunks from the stream, returning only the count. Useful for testing, benchmarking, or draining streams when you only need to know how many items were produced.