🎯 Creates an object composed of the object properties that do not satisfy the predicate.

Syntax

TypeScript
import { omitBy } from '@opentf/std';

omitBy<T extends object>(
  obj: T,
  predicate: (value: any, key: string | symbol) => boolean
): Partial<T>;

Parameters

  • obj: The source object.

  • predicate: The function invoked per iteration. Enumerable symbol keys are included.

When the source object uses Object.create(null), the returned object preserves that null prototype.

Returns

A new object with omitted properties.

Examples

TypeScript
const object = { a: 1, b: 'abc', c: 3 };

omitBy(object, (v) => typeof v === 'number')
//=> { b: 'abc' }
Last updated on
Edit this page