export interface ReadableStreamEvents { /** * The 'data' event is emitted whenever the stream is * relinquishing ownership of a chunk of data to a consumer. * * NOTE: PLEASE UNDERSTAND THAT ADDING A DATA LISTENER CAN * TURN THE STREAM INTO FLOWING MODE. IT IS THEREFOR THE * LAST LISTENER THAT SHOULD BE ADDED AND NOT THE FIRST * * Use `listenStream` as a helper method to listen to * stream events in the right order. */ on(event: 'data', callback: (data: T) => void): void; /** * Emitted when any error occurs. */ on(event: 'error', callback: (err: Error) => void): void; /** * The 'end' event is emitted when there is no more data * to be consumed from the stream. The 'end' event will * not be emitted unless the data is completely consumed. */ on(event: 'end', callback: () => void): void; } /** * A interface that emulates the API shape of a node.js readable * stream for use in native and web environments. */ export interface ReadableStream extends ReadableStreamEvents { /** * Stops emitting any events until resume() is called. */ pause(): void; /** * Starts emitting events again after pause() was called. */ resume(): void; /** * Destroys the stream and stops emitting any event. */ destroy(): void; /** * Allows to remove a listener that was previously added. */ removeListener(event: string, callback: Function): void; } /** * A interface that emulates the API shape of a node.js readable * for use in native and web environments. */ export interface Readable { /** * Read data from the underlying source. Will return * null to indicate that no more data can be read. */ read(): T | null; }