Object
pickBy

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

Syntax

import { pickBy } from '@opentf/std';
 
pickBy<T extends object>(
  obj: T,
  predicate: (value: any, key: string) => boolean
): Partial<T>;

Parameters

  • obj: The source object.
  • predicate: The function invoked per iteration.

Returns

A new object with picked properties.

Examples

const object = { a: 1, b: 'abc', c: 3 };
 
pickBy(object, (v) => typeof v === 'number')
//=> { a: 1, c: 3 }

Related

Try