s-flatten
Version:
A flatten function for Web Streams
36 lines (22 loc) • 642 B
Markdown
A flatten function for Web Streams. Like `Array.prototype.flat()`, but for Web Streams.
```bash
npm install s-flatten
```
```js
import sFlatten from "s-flatten";
const stream = ReadableStream.from([
[],
[],
]).pipeThrough(sFlatten());
const result = await Array.fromAsync(stream);
console.log(result); // [1, 2, 3, 4]
```
Returns a `TransformStream<T[], T>` that flattens the input stream.
- [s-batch](https://github.com/trevorah/s-batch) - Batch items in a stream
- [s-compose](https://github.com/trevorah/s-compose) - Compose streams together