ts-data-forge
    Preparing search index...
    • Creates a new record that excludes the specified keys from the source record. This function supports both direct usage and curried form for functional composition.

      Type Safety: Only keys that exist in the source record type are allowed, and the return type precisely reflects which properties remain after omission.

      Type Parameters

      • const R extends UnknownRecord

        The type of the input record

      • const Keys extends readonly (keyof R)[]

        The readonly array type of keys to omit from the record

      Parameters

      • record: R

        The source record to omit properties from

      • keys: Keys

        A readonly array of keys to exclude from the result

      Returns Omit<R, ArrayElement<Keys>>

      A new record containing all properties except the specified keys

      const user = {
      id: 1,
      name: 'Charlie',
      email: 'charlie@example.com',
      password: 'secret123',
      internalNote: 'VIP customer',
      };

      // Direct usage - remove sensitive fields
      const safeUser = Obj.omit(user, ['password', 'internalNote']);

      assert.deepStrictEqual(safeUser, {
      id: 1,
      name: 'Charlie',
      email: 'charlie@example.com',
      });

      // Curried usage with pipe
      const withoutEmail = pipe(user).map(Obj.omit(['email', 'password'])).value;

      assert.deepStrictEqual(withoutEmail, {
      id: 1,
      name: 'Charlie',
      internalNote: 'VIP customer',
      });
    • Creates a new record that excludes the specified keys from the source record. This function supports both direct usage and curried form for functional composition.

      Type Safety: Only keys that exist in the source record type are allowed, and the return type precisely reflects which properties remain after omission.

      Type Parameters

      • const Keys extends readonly PropertyKey[]

        The readonly array type of keys to omit from the record

      Parameters

      • keys: Keys

        A readonly array of keys to exclude from the result

      Returns <const R extends UnknownRecord>(record: R) => Omit<R, ArrayElement<Keys>>

      A new record containing all properties except the specified keys

      const user = {
      id: 1,
      name: 'Charlie',
      email: 'charlie@example.com',
      password: 'secret123',
      internalNote: 'VIP customer',
      };

      // Direct usage - remove sensitive fields
      const safeUser = Obj.omit(user, ['password', 'internalNote']);

      assert.deepStrictEqual(safeUser, {
      id: 1,
      name: 'Charlie',
      email: 'charlie@example.com',
      });

      // Curried usage with pipe
      const withoutEmail = pipe(user).map(Obj.omit(['email', 'password'])).value;

      assert.deepStrictEqual(withoutEmail, {
      id: 1,
      name: 'Charlie',
      internalNote: 'VIP customer',
      });