🎯 Creates an object composed of the object properties that satisfy the predicate.
Syntax
TypeScript
import { pickBy } from '@opentf/std'; pickBy<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 picked properties.
Examples
TypeScript
const object = { a: 1, b: 'abc', c: 3 }; pickBy(object, (v) => typeof v === 'number') //=> { a: 1, c: 3 }