UNPKG

@queso/pick

Version:

Creates an object composed of the picked object properties.

55 lines (36 loc) 1.5 kB
# @queso/pick [![npm license](http://img.shields.io/npm/l/@queso/pick.svg)](https://www.npmjs.org/package/@queso/pick) [![Travis Build Status](https://img.shields.io/travis/jedmao/queso.svg)](https://travis-ci.org/jedmao/queso) [![codecov](https://codecov.io/gh/jedmao/queso/branch/master/graph/badge.svg)](https://codecov.io/gh/jedmao/queso) [![Try @queso/pick on RunKit](https://badge.runkitcdn.com/@queso/pick.svg)](https://npm.runkit.com/@queso/pick) Part of a [library](../../../../) of zero-dependency npm modules that do just one thing. - 100% [TypeScript](http://www.typescriptlang.org/) support. - It's not a party without [`Queso`](../../../../)! [![npm](https://nodei.co/npm/@queso/pick.svg?downloads=true)](https://nodei.co/npm/@queso/pick/) min + gzip | 99 bytes [source](https://github.com/jedmao/queso/blob/master/src/packages/pick/pick.ts) Creates an object composed of the picked `object` properties. ## Usage ```ts import pick from '@queso/pick' const obj = { a: 1, b: 2, c: 3 } pick(obj, 'a', 'c') // => { a: 1, c: 3 } ``` ## Parameters | Name | Type | Description | | :------- | :---- | :-------------------------- | | `object` | `T` | The source object. | | `paths` | `K[]` | The property paths to pick. | ### Type parameters | Name | Constraint | | :--- | :--------- | | `T` | `object` | | `K` | `keyof T` | ## Returns A new object composed of the picked `object` properties. ### Return type ```ts Partial<Pick<T, K>> ```