Skip to content

reject

ts
function Array.reject<T>(
    target: readonly T[],
    predicate: (
        value: NoInfer<T>,
        index: number,
        target: readonly NoInfer<T>[],
    ) => boolean,
): readonly T[]

Returns a new array with elements from array that do not satisfy the provided predicate function.

Example

ts
import { Array } from "@monstermann/array";

Array.reject([1, 2, 3, 4, 5], (x) => x % 2 === 0); // [1, 3, 5]
ts
import { Array } from "@monstermann/array";

pipe(
    [1, 2, 3, 4, 5],
    Array.reject((x) => x % 2 === 0),
); // [1, 3, 5]