@lavadrop/pick-by
TypeScript icon, indicating that this package has built-in type declarations

0.3.0 • Public • Published

@lavadrop/pick-by

npm license Travis Build Status codecov Try @lavadrop/pick-by on RunKit

Part of a library of zero-dependency npm modules that do just one thing.

npm

min + gzip | 124 bytes

source

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

Usage

import pickBy from '@lavadrop/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>

Package Sidebar

Install

npm i @lavadrop/pick-by

Weekly Downloads

2

Version

0.3.0

License

MIT

Unpacked Size

10.2 kB

Total Files

8

Last publish

Collaborators

  • jedmao