Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/Borewit/readable-web-to-node-stream
Converts a Web-API readable-stream into a Node readable-stream.
https://github.com/Borewit/readable-web-to-node-stream
adapter converter node readable readable-stream stream web
Last synced: 3 months ago
JSON representation
Converts a Web-API readable-stream into a Node readable-stream.
- Host: GitHub
- URL: https://github.com/Borewit/readable-web-to-node-stream
- Owner: Borewit
- Created: 2019-05-01T20:06:00.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2023-01-31T04:01:31.000Z (almost 2 years ago)
- Last Synced: 2024-08-23T01:42:02.604Z (4 months ago)
- Topics: adapter, converter, node, readable, readable-stream, stream, web
- Language: TypeScript
- Size: 2.08 MB
- Stars: 44
- Watchers: 2
- Forks: 8
- Open Issues: 20
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
[![CI browser tests](https://github.com/Borewit/readable-web-to-node-stream/actions/workflows/xvfb-ci.yml/badge.svg)](https://github.com/Borewit/readable-web-to-node-stream/actions/workflows/xvfb-ci.yml)
[![NPM version](https://badge.fury.io/js/readable-web-to-node-stream.svg)](https://npmjs.org/package/readable-web-to-node-stream)
[![npm downloads](http://img.shields.io/npm/dm/readable-web-to-node-stream.svg)](https://npmcharts.com/compare/readable-web-to-node-stream)
[![Known Vulnerabilities](https://snyk.io/test/github/Borewit/readable-web-to-node-stream/badge.svg?targetFile=package.json)](https://snyk.io/test/github/Borewit/readable-web-to-node-stream?targetFile=package.json)
[![Codacy Badge](https://app.codacy.com/project/badge/Grade/d4b511481b3a4634b6ca5c0724407eb9)](https://www.codacy.com/gh/Borewit/peek-readable/dashboard?utm_source=github.com&utm_medium=referral&utm_content=Borewit/peek-readable&utm_campaign=Badge_Grade)
[![Coverage Status](https://coveralls.io/repos/github/Borewit/readable-web-to-node-stream/badge.svg?branch=master)](https://coveralls.io/github/Borewit/readable-web-to-node-stream?branch=master)
[![Minified size](https://badgen.net/bundlephobia/min/readable-web-to-node-stream)](https://bundlephobia.com/result?p=readable-web-to-node-stream)# readable-web-to-node-stream
Converts a [Web-API readable stream](https://developer.mozilla.org/en-US/docs/Web/API/ReadableStreamDefaultReader) into a [Node.js readable stream](https://nodejs.org/api/stream.html#stream_readable_streams).
## Installation
Install via [npm](http://npmjs.org/):```bash
npm install readable-web-to-node-stream
```
or [yarn](https://yarnpkg.com/):
```bash
yarn add readable-web-to-node-stream
```## Compatibility
Source is written in TypeScript and compiled to ECMAScript 2017 (ES8).
Unit tests are performed on the following browsers:
* Latest Google Chrome 74.0
## ExampleImport readable-web-stream-to-node in JavaScript:
```js
const {ReadableWebToNodeStream} = require('readable-web-to-node-stream');async function download(url) {
const response = await fetch(url);
const readableWebStream = response.body;
const nodeStream = new ReadableWebToNodeStream(readableWebStream);
}
```## API
**constructor(stream: ReadableStream): Promise**
`stream: ReadableStream`: the [Web-API readable stream](https://developer.mozilla.org/en-US/docs/Web/API/ReadableStreamDefaultReader).
**close(): Promise**
Will cancel close the Readable-node stream, and will release Web-API-readable-stream.**waitForReadToComplete(): Promise**
If there is no unresolved read call to Web-API ReadableStream immediately returns, otherwise it will wait until the read is resolved.## Licence
(The MIT License)
Copyright (c) 2019 Borewit
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.