1.0.1 • Published 6 months ago

s-flatten v1.0.1

Weekly downloads
-
License
MIT
Repository
github
Last release
6 months ago

s-flatten

A flatten function for Web Streams. Like Array.prototype.flat(), but for Web Streams.

Installation

npm install s-flatten

Usage

import sFlatten from "s-flatten";

const stream = ReadableStream.from([
  [1, 2],
  [3, 4],
]).pipeThrough(sFlatten());

const result = await Array.fromAsync(stream);

console.log(result); // [1, 2, 3, 4]

API

sFlatten()

Returns a TransformStream<T[], T> that flattens the input stream.

Related