Skip to content

Converts a Node.js Readable stream into a WHATWG-compatible ReadableStream.

License

Notifications You must be signed in to change notification settings

Borewit/node-readable-to-web-readable-stream

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

CI NPM version NPM downloads

node-readable-to-web-readable-stream

node-readable-to-web-readable-stream is a utility that converts a Node.js Readable stream into a WHATWG-compatible ReadableStream. This is particularly useful for integrating Node.js streams with web-native streaming APIs.

Installation

Install the package using npm:

npm install node-readable-to-web-readable-stream

Or with yarn:

yarn add node-readable-to-web-readable-stream

Usage

Here's how you can use this utility to convert a Node.js Readable stream into a web ReadableStream:

import {makeByteReadableStreamFromNodeReadable} from 'node-readable-to-web-readable-stream';
import {createReadStream} from 'fs';

// Create a Node.js Readable stream
const nodeReadable = fs.createReadStream('example.txt');

// Convert to a web ReadableStream
const webReadable = makeByteReadableStreamFromNodeReadable(nodeReadable);

// Now you can use webReadable as a WHATWG ReadableStream

Compatibility

This is an ECMAScript Module (ESM).

API

toWebReadableStream(nodeReadable)

  • Parameters:

    • nodeReadable (Node.js Readable): The Node.js Readable stream to convert.
  • Returns:

    • A WHATWG-compatible ReadableStream.

License

This project is licensed under the MIT License. See the LICENSE file for details.

About

Converts a Node.js Readable stream into a WHATWG-compatible ReadableStream.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published