Skip to content

pick()

pick<T>(object, keys): Partial<T>

Defined in: src/utils/objectUtils.ts:91

Picks specified keys from an object.

Type Parameters

T extends Record<string, unknown>

Parameters

object

T

The object to pick properties from.

keys

keyof T[]

The keys to pick.

Returns

Partial<T>

A new object containing only the specified keys.

Example

tsx
const obj = { a: 1, b: 2, c: 3 };
const picked = pick(obj, ['a', 'c']);
console.log(picked); // { a: 1, c: 3 }

Released under the MIT License.