pragmatic-fp-ts
Version:
Opinionated functional programming library with easy use in mind
16 lines (11 loc) • 458 B
text/typescript
import { Predicate } from "./main.ts";
// true if no list elements passes the predicate
export function none<A>(pred: Predicate<A>, coll: A[]): boolean;
export function none<A>(pred: Predicate<A>): (coll: A[]) => boolean;
export function none<A>(pred: Predicate<A>, coll?: A[]) {
if (arguments.length === 1) return (_coll: A[]) => none(pred, _coll);
for (let i = 0; i < coll!.length; ++i) {
if (pred(coll![i])) return false;
}
return true;
}