@queso/pick-by
v0.1.0
Published
Creates an object composed of the object properties for which predicate returns truthy.
Downloads
24
Maintainers
Readme
@queso/pick-by
Part of a library of zero-dependency npm modules that do just one thing.
- 100% TypeScript support.
- It's not a party without
Queso
!
min + gzip | 124 bytes
Creates an object composed of the object properties for which predicate returns truthy.
Usage
import pickBy from '@queso/pick-by'
const obj = { a: 0, b: '', c: true, d: 'hello' }
pickBy(obj)
// => { c: true, d: 'hello' }
Parameters
| Name | Type | Description |
| :---------- | :------------------------------------------------ | :--------------------------------- |
| object
| T
| The source object. |
| predicate
| <K extends keyof T>(value: T[K], key: K) => any
| The function invoked per property. |
Type parameters
| Name | Constraint |
| :--- | :--------- |
| T
| object
|
| K
| keyof T
|
Returns
The new object.
Return type
Partial<T>