x/evt@v1.10.2/tools/reducers/contains.ts

šŸ’§EventEmitter's typesafe replacement
GitHub Stars
382
Go to Latest

import { toReduceArguments, ReduceArguments } from "./reduceify.ts";
export function arrContains<ArrOf>( arr: readonly ArrOf[], matcher: (e: ArrOf) => boolean): boolean {
for( const entry of arr ){
if( !matcher(entry) ){ continue; }
return true;
}
return false;
}

export function contains<ArrOf>( matcher: (e: ArrOf) => boolean): ReduceArguments<ArrOf, boolean> { return toReduceArguments(arrContains, matcher);}