( writable: Writable, writableError: WritableErrorMonitor, )
| 109 | } |
| 110 | |
| 111 | function waitForDrain( |
| 112 | writable: Writable, |
| 113 | writableError: WritableErrorMonitor, |
| 114 | ): Promise<void> { |
| 115 | let cleanup = () => {}; |
| 116 | let drainPromise = new Promise<void>((resolve) => { |
| 117 | function onDrain() { |
| 118 | cleanup(); |
| 119 | resolve(); |
| 120 | } |
| 121 | |
| 122 | cleanup = function cleanup() { |
| 123 | writable.off("drain", onDrain); |
| 124 | }; |
| 125 | |
| 126 | writable.once("drain", onDrain); |
| 127 | }); |
| 128 | |
| 129 | return writableError.race(drainPromise).finally(cleanup); |
| 130 | } |
| 131 | |
| 132 | export async function writeAsyncIterableToWritable( |
| 133 | iterable: AsyncIterable<Uint8Array>, |
no test coverage detected
searching dependent graphs…