import { wrapWithAbort } from './operators/withabort' ; import { throwIfAborted } from '../aborterror' ; template TSource param { AsyncIterable < TSource > } source param { AbortSignal } signal returns { Promise < TSource [ ] > } export async function toArray < TSource > ( source , signal ? ) { throwIfAborted ( signal ) ; const results = [ ] as TSource [ ] ; for await ( const item of wrapWithAbort ( source , signal ) ) { results . push ( item ) ; } return results ; }