/** * Sink for `*`, from * ```bnf * response ::= * * ``` * Collects a bounded list of responses up to `maxResponses` */ export async function collectMaxResponse(source: AsyncIterable, maxResponses: number): Promise { // else: zero or more responses const responses: T[] = []; for await (const response of source) { responses.push(response); if (maxResponses !== undefined && responses.length >= maxResponses) { break; } } return responses; }