Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/kettanaito/readable-stream-polyfill

"ReadableStream" polyfill based on the eponymous implementation from Node.js.
https://github.com/kettanaito/readable-stream-polyfill

controller nodejs polyfill readable readablestream stream

Last synced: 1 day ago
JSON representation

"ReadableStream" polyfill based on the eponymous implementation from Node.js.

Awesome Lists containing this project

README

        

# `ReadableStream`

A [WHATWG-compliant](https://streams.spec.whatwg.org/#readablestream) polyfill for `ReadableStream` based on the eponymous implementation in Node.js.

## Install

```sh
npm install readable-stream-polyfill
```

## Node.js API

```js
const { ReadableStream } = require('readable-stream-polyfill')

const stream = new ReadableStream({
start(controller) {
controller.enqueue('hello')
controller.enqueue('world')
controller.end()
},
})

const reader = await stream.getReader()
```

## Polyfill

```js
// Polyfills the global "ReadableStream" class
// if it's not already implemented.
require('readable-stream-polyfill/globals')
```

## Usage

- [`ReadableStream` on MDN](https://developer.mozilla.org/en-US/docs/Web/API/ReadableStream)