Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | 3x 3x 12x 12x | import { not, Predicate } from "@benneq/predicate";
import { some } from "./some";
/**
* Creates a {@link Predicate} that checks if all elements of an {@link Array}
* match a {@link Predicate}.
*
* Returns `true` if the `array` is empty.
*
* @param predicate - the {@link Predicate} to match
* @param fromIndex - the optional array index to begin with, defaults to `0`
* @returns `true` if all elements match the `predicate`, otherwise `false`
*/
export const every = <T>(
predicate: Predicate<[T, number, ArrayLike<T>]>,
fromIndex?: number
): Predicate<[ArrayLike<T>]> => {
return not(some(not(predicate), fromIndex));
};
|