GuobaGuoba Utils

pick

@guoba-ai/utils / object / pick

Function: pick()

function pick<T, K>(obj, keys): Pick<T, K>;

Defined in: object.ts:78

Create a new object with only the specified keys.

Type Parameters

T

T extends object

K

K extends string | number | symbol

Parameters

obj

T

The source object

keys

K[]

Keys to pick

Returns

Pick<T, K>

A new object with only the specified keys

Example

pick({ a: 1, b: 2, c: 3 }, ['a', 'c']) // { a: 1, c: 3 }

On this page