0.8.0 • Published 5 years ago

@lavadrop/pick v0.8.0

Weekly downloads
195
License
MIT
Repository
github
Last release
5 years ago

@lavadrop/pick

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

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

npm

min + gzip | 99 bytes

source

Creates an object composed of the picked object properties.

Usage

import pick from '@lavadrop/pick'

const obj = { a: 1, b: 2, c: 3 }
pick(obj, 'a', 'c')
// => { a: 1, c: 3 }

Parameters

NameTypeDescription
objectTThe source object.
pathsK[]The property paths to pick.

Type parameters

NameConstraint
Tobject
Kkeyof T

Returns

A new object composed of the picked object properties.

Return type

Partial<Pick<T, K>>