Skip to content
Myr

web.js

This file

Path

lib/convert/web.js

7 lines · 614 bytes · JavaScript

Last changed by

Add `.readableStream()`, `.writableStream()` and `.transformStream()` methods (#1254)Sindre Sorhusbefore adoption29d9cfc

History of this file

Take it

Add `.readableStream()`, `.writableStream()` and `.transformStream()` methods (#1254)Sindre Sorhusbefore adoption29d9cfc

lines 1–7why, one step back
1import {Readable, Writable, Duplex} from 'node:stream';
23// Web stream versions of `subprocess.readable()`, `subprocess.writable()` and `subprocess.duplex()`.4// They wrap those methods with `.toWeb()`, so all error and abort handling is reused as is.5export const createReadableStream = (subprocess, readableOptions) => Readable.toWeb(subprocess.readable(readableOptions));6export const createWritableStream = (subprocess, writableOptions) => Writable.toWeb(subprocess.writable(writableOptions));7export const createTransformStream = (subprocess, duplexOptions) => Duplex.toWeb(subprocess.duplex(duplexOptions));