-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Drop support for native Node Readable stream: require manual conversi…
…on to Node Web Streams Utils to convert from and to Web Streams in Node are available from v17, see https://nodejs.org/api/stream.html#streamreadabletowebstreamreadable-options . Previously, we automatically converted between Node native streams and custom, Web-like Readable streams. This led to occasional issues.
- Loading branch information
Showing
14 changed files
with
47 additions
and
130 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,11 @@ | ||
/// <reference lib="dom" /> | ||
|
||
import { ReadableStream as NodeWebReadableStream } from 'node:stream/web'; | ||
type Data = Uint8Array | string; | ||
|
||
export type WebStream<T extends Data> = ReadableStream<T>; | ||
|
||
interface NodeStream<T extends Data> extends AsyncIterable<T> { // copied+simplified version of ReadableStream from @types/node/index.d.ts, which does no support generics | ||
readable: boolean; pipe: Function; unpipe: Function; wrap: Function; setEncoding(encoding: string): this; pause(): this; resume(): this; | ||
isPaused(): boolean; unshift(chunk: string | Uint8Array): void; | ||
read(size?: number): T; | ||
} | ||
export type WebStream<T extends Data> = ReadableStream<T> | ||
export type NodeWebStream<T extends Data> = NodeWebReadableStream<T>; | ||
|
||
type Stream<T extends Data> = WebStream<T> | NodeStream<T>; | ||
type Stream<T extends Data> = WebStream<T> | NodeWebStream<T>; | ||
type MaybeStream<T extends Data> = T | Stream<T>; | ||
|
||
export function readToEnd<T extends Data, R extends any = T>(input: MaybeStream<T>, join?: (chunks: T[]) => R): Promise<R>; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,3 @@ | ||
export * from './streams.js'; | ||
|
||
export { webToNode, nodeToWeb } from './node-conversions/index.js'; | ||
|
||
export { isStream, isArrayStream, isUint8Array, concatUint8Array } from './util.js'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,2 @@ | ||
export const NodeReadableStream = null; | ||
export const NodeBuffer = null; | ||
export const webToNode = null; | ||
export const nodeToWeb = null; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
export { webToNode, nodeToWeb, NodeBuffer, NodeReadableStream } from './node.js'; | ||
export { NodeBuffer, NodeReadableStream } from './node.js'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,6 @@ | |
"./node.js": "./browser-fallback.js" | ||
}, | ||
"exports": { | ||
".": "index.js" | ||
".": "./index.js" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters