MCPcopy
hub / github.com/sindresorhus/got / expectStreamToEnd

Function expectStreamToEnd

test/stream.ts:51–63  ·  view source on GitHub ↗
(stream: NodeJS.ReadableStream & NodeJS.EventEmitter)

Source from the content-addressed store, hash-verified

49};
50
51async function expectStreamToEnd(stream: NodeJS.ReadableStream & NodeJS.EventEmitter): Promise<void> {
52 await Promise.race([
53 new Promise<void>((resolve, reject) => {
54 stream.on('error', reject);
55 stream.on('end', resolve);
56 stream.resume();
57 }),
58 (async () => {
59 await delay(1000);
60 throw new Error('Timed out waiting for stream end');
61 })(),
62 ]);
63}
64
65test('stream reads a cookie and completes', withServer, async (t, server, got) => {
66 server.get('/', (_request, response) => {

Callers 1

stream.tsFile · 0.85

Calls 1

delayFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…