import { ArgumentOutOfRangeException } from "../../shared" ; param source param index throws returns export const elementAt = async < TSource > ( source , index ) : Promise < TSource > => { if ( index < 0 ) { throw new ArgumentOutOfRangeException ( "index" ) ; } let i = 0 ; for await ( const item of source ) { if ( index === i ++ ) { return item ; } } throw new ArgumentOutOfRangeException ( "index" ) ; } ;