Function rejectObject

Rejects object properties based on a predicate function. Opposite of filterObject - only includes properties where the predicate returns false.

const isEven = (x: number) => x % 2 === 0;
rejectObject(isEven)({ a: 1, b: 2, c: 3, d: 4 });
// => { a: 1, c: 3 }
  • Type Parameters

    • T extends Record<string, unknown>

      Object value type

    Parameters

    • predicate: (value: unknown) => boolean

      Function that returns true for values to exclude

    Returns (obj: T) => Partial<T>

    New object with rejected properties removed