@swimburger/isomorphic-streams
TypeScript icon, indicating that this package has built-in type declarations

1.1.1 • Public • Published

This is a fork of https://github.com/ksm2/isomorphic-streams


isomorphic-streams

Build NPM version license

Isomorphic WHATWG Streams API package for browser, Node.js, and other runtimes.

This package has

  • zero dependencies
  • provides TypeScript typings
  • supports ReadableStream, WritableStream and TransformStream

Table of Contents

Install

Use either

yarn add isomorphic-streams

or

npm install isomorphic-streams

Usage

In the browser: Instead of using the global ReadbaleStream or window.ReadableStream, import from this package instead.

In Node.js: Instead of importing node:stream/web or requiring stream/web, import from this package instead.

The following code will work in both Node.js and the browser:

import { ReadableStream } from "isomorphic-streams";

const SECOND = 1000;

const stream = new ReadableStream({
  start(controller) {
    setInterval(() => {
      controller.enqueue(Date.now());
    }, SECOND);
  },
});

for await (const value of stream) {
  console.log(value);
}

More examples

Contributing

This project is open to feedback and contributions, please open an issue.

isomorphic-streams follows the Contributor Covenant Code of Conduct.

License

MIT © 2023 Niels Swimberghe, see LICENSE.

Package Sidebar

Install

npm i @swimburger/isomorphic-streams

Weekly Downloads

1

Version

1.1.1

License

MIT

Unpacked Size

22.5 kB

Total Files

15

Last publish

Collaborators

  • swimburger