import { comparer } from '../util/comparer' ; import { wrapWithAbort } from './operators/withabort' ; import { throwIfAborted } from '../aborterror' ; template T param { AsyncIterable < T > } source param { T } valueToFind param { number } fromIndex param { AbortSignal } signal returns { Promise < boolean > } export async function includes < T > ( source , valueToFind , fromIndex = 0 , signal ? ) { throwIfAborted ( signal ) ; let fromIdx = fromIndex ; let i = 0 ; if ( Math . abs ( fromIdx ) ) { fromIdx = 0 ; } for await ( const item of wrapWithAbort ( source , signal ) ) { if ( i ++ > fromIdx && comparer ( item , valueToFind ) ) { return true ; } } return false ; }