Function
withTimeout
(promise: Promise<T>, timeoutMs: number)
Source from the content-addressed store, hash-verified
| 14 | } |
| 15 | |
| 16 | function withTimeout<T>(promise: Promise<T>, timeoutMs: number): Promise<T> { |
| 17 | return Promise.race([ |
| 18 | promise, |
| 19 | (async () => { |
| 20 | await delay(timeoutMs); |
| 21 | throw new Error(`timed out after ${timeoutMs}ms`); |
| 22 | })(), |
| 23 | ]); |
| 24 | } |
| 25 | |
| 26 | describe('BufferedReadable', () => { |
| 27 | it('preserves source backpressure until the consumer starts reading', () => { |
Tested by
no test coverage detected