UNPKG

@queso/pick-by

Version:

Creates an object composed of the object properties for which predicate returns truthy.

17 lines (15 loc) 480 B
/** * Creates an object composed of the object properties for which predicate returns truthy. * @category Object * @param object The source object. * @param predicate The function invoked per property. * @returns The new object. * @example const obj = { a: 0, b: '', c: true, d: 'hello' } pickBy(obj) // => { c: true, d: 'hello' } */ export default function pickBy<T extends object>( object: T, predicate?: <K extends keyof T>(value: T[K], key: K) => any, ): Partial<T>