Skip to content

pick

Select specific properties from an object and return a new object.

Usage

typescript
import { pick } from '@preflower/utils'

const user = { id: 1, name: 'Alice', email: 'alice@example.com' }
const summary = pick(user, ['id', 'name'])
// { id: 1, name: 'Alice' }

Parameters

NameTypeDescription
targetT extends objectThe source object.
keysArray<keyof T>List of keys to pick from the target.

Released under the ISC License.