@@ -20,62 +20,6 @@ export function getDefaultFetch(): Fetch {
2020 ) ;
2121}
2222
23- /**
24- * A minimal copy of the NodeJS `stream.Readable` class so that we can
25- * accept the NodeJS types in certain places, e.g. file uploads
26- *
27- * https://nodejs.org/api/stream.html#class-streamreadable
28- */
29- export interface ReadableLike {
30- readable : boolean ;
31- readonly readableEnded : boolean ;
32- readonly readableFlowing : boolean | null ;
33- readonly readableHighWaterMark : number ;
34- readonly readableLength : number ;
35- readonly readableObjectMode : boolean ;
36- destroyed : boolean ;
37- read ( size ?: number ) : any ;
38- pause ( ) : this;
39- resume ( ) : this;
40- isPaused ( ) : boolean ;
41- destroy ( error ?: Error ) : this;
42- [ Symbol . asyncIterator ] ( ) : AsyncIterableIterator < any > ;
43- }
44-
45- /**
46- * Determines if the given value looks like a NodeJS `stream.Readable`
47- * object and that it is readable, i.e. has not been consumed.
48- *
49- * https://nodejs.org/api/stream.html#class-streamreadable
50- */
51- export function isReadableLike ( value : any ) {
52- // We declare our own class of Readable here, so it's not feasible to
53- // do an 'instanceof' check. Instead, check for Readable-like properties.
54- return ! ! value && value . readable === true && typeof value . read === 'function' ;
55- }
56-
57- /**
58- * A minimal copy of the NodeJS `fs.ReadStream` class for usage within file uploads.
59- *
60- * https://nodejs.org/api/fs.html#class-fsreadstream
61- */
62- export interface FsReadStreamLike extends ReadableLike {
63- path : { } ; // real type is string | Buffer but we can't reference `Buffer` here
64- }
65-
66- /**
67- * Determines if the given value looks like a NodeJS `fs.ReadStream`
68- * object.
69- *
70- * This just checks if the object matches our `Readable` interface
71- * and defines a `path` property, there may be false positives.
72- *
73- * https://nodejs.org/api/fs.html#class-fsreadstream
74- */
75- export function isFsReadStreamLike ( value : any ) : value is FsReadStreamLike {
76- return isReadableLike ( value ) && 'path' in value ;
77- }
78-
7923type ReadableStreamArgs = ConstructorParameters < typeof ReadableStream > ;
8024
8125export function makeReadableStream ( ...args : ReadableStreamArgs ) : ReadableStream {
0 commit comments