Skip to content

Commit a40eb24

Browse files
robhoganfacebook-github-bot
authored andcommitted
Add Flow lib defs for Node.js streams fromWeb/toWeb
Summary: Since v17 (and stable since v22.17), Node.js has helper methods for converting [Node streams](https://nodejs.org/api/stream.html) to/from [Web streams](https://developer.mozilla.org/en-US/docs/Web/API/Streams_API) (e.g., as returned by global `fetch`). This adds the Flow typings. - Node docs: https://nodejs.org/api/stream.html#streamreadablefromwebreadablestream-options Changelog: [General][Internal] Monorepo Flow typings Differential Revision: D87543561
1 parent de3d54a commit a40eb24

1 file changed

Lines changed: 29 additions & 0 deletions

File tree

flow-typed/environment/node.js

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2459,6 +2459,13 @@ declare class stream$Readable extends stream$Stream {
24592459
options?: readableStreamOptions,
24602460
): stream$Readable;
24612461

2462+
static fromWeb(
2463+
readableStream: ReadableStream,
2464+
options?: readableStreamOptions,
2465+
): stream$Readable;
2466+
2467+
static toWeb(streamReadable: stream$Readable): ReadableStream;
2468+
24622469
constructor(options?: readableStreamOptions): void;
24632470
destroy(error?: Error): this;
24642471
isPaused(): boolean;
@@ -2504,6 +2511,13 @@ type writableStreamOptions = {
25042511
...
25052512
};
25062513
declare class stream$Writable extends stream$Stream {
2514+
static fromWeb(
2515+
writableStream: WritableStream,
2516+
options?: writableStreamOptions,
2517+
): stream$Writable;
2518+
2519+
static toWeb(streamWritable: stream$Writable): WritableStream;
2520+
25072521
constructor(options?: writableStreamOptions): void;
25082522
cork(): void;
25092523
destroy(error?: Error): this;
@@ -2559,6 +2573,21 @@ type duplexStreamOptions = writableStreamOptions &
25592573
...
25602574
};
25612575
declare class stream$Duplex extends stream$Readable mixins stream$Writable {
2576+
static fromWeb(
2577+
pair: {
2578+
readable: ReadableStream,
2579+
writable: WritableStream,
2580+
...
2581+
},
2582+
options?: duplexStreamOptions,
2583+
): stream$Duplex;
2584+
2585+
static toWeb(streamDuplex: stream$Duplex): {
2586+
readable: ReadableStream,
2587+
writable: WritableStream,
2588+
...
2589+
};
2590+
25622591
constructor(options?: duplexStreamOptions): void;
25632592
}
25642593
type transformStreamOptions = duplexStreamOptions & {

0 commit comments

Comments
 (0)