@luolapeikko/ts-common
    Preparing search index...

    Function propNotEquals

    • Creates a predicate function that checks whether a given object's property does not equal the specified value.

      Supports both strictly typed object structures and looser records with optional properties.

      Useful for filtering arrays of objects where you want to exclude items with a certain property value.

      Type Parameters

      • T extends Record<PropertyKey, any>

        The object type with known keys (strict overload).

      • K extends string | number | symbol

        The key of the property to compare.

      Parameters

      • key: K

        The property name to compare.

      • value: T[K]

        The value to check against.

      Returns (obj: T) => boolean

      A predicate function returning true when obj[key] !== value.

      // Strict object structure
      const isNotAdmin = propNotEquals<User, 'role'>('role', 'admin');
      const nonAdmins = users.filter(isNotAdmin);
      // Loosely typed object
      const isNotPublished = propNotEquals('status', 'published');
      const draftsOrArchived = posts.filter(isNotPublished);
    • Creates a predicate function that checks whether a given object's property does not equal the specified value.

      Supports both strictly typed object structures and looser records with optional properties.

      Useful for filtering arrays of objects where you want to exclude items with a certain property value.

      Type Parameters

      • V

        The value type of the property (loose overload).

      • K extends PropertyKey

        The key of the property to compare.

      Parameters

      • key: K

        The property name to compare.

      • value: V

        The value to check against.

      Returns (obj: Partial<Record<K, V>>) => boolean

      A predicate function returning true when obj[key] !== value.

      // Strict object structure
      const isNotAdmin = propNotEquals<User, 'role'>('role', 'admin');
      const nonAdmins = users.filter(isNotAdmin);
      // Loosely typed object
      const isNotPublished = propNotEquals('status', 'published');
      const draftsOrArchived = posts.filter(isNotPublished);