API Reference

streamfu provides 22 functions organized in three categories.

Rule of thumb: If it returns a ReadableStream, it’s non-consuming. If it returns a Promise, it consumes the stream.


Creation

Functions that create new streams from various data sources.

Function Description
createReadable(iterable)  
createWritable(fn)  
range(min, max, step?)  
words(chars, length)  

Transformations (non-consuming)

These return a new ReadableStream — the original is not consumed.

Function Description
map(stream, ...fns)  
filter(stream, fn)  
flat(stream, depth?)  
flatMap(stream, fn)  
slice(stream, start, end?)  
splice(stream, start, count, ...items)  
concat(...streams)  
zip(...streams)  
pipe(stream, ...fns)  
branch(stream, n)  

Consumers (consuming)

These consume the stream and return a Promise — it cannot be reused afterward. Use branch() first if you need to consume a stream multiple times.

Function Description
reduce(stream, fn, init)  
list(stream)  
at(stream, index)  
some(stream, fn)  
every(stream, fn)  
forEach(stream, fn)  
includes(stream, value)  
indexOf(stream, value)