Saltar al contenido principal

Function: usePick()

usePick<T, K>(obj, keys): Pick<T, K>

Defined in: src/core/services/utils.service.ts:177

Picks the listed keys from an object into a new object.

Type Parameters

T

T extends object

Source object type.

K

K extends string | number | symbol

Keys to pick.

Parameters

obj

T

The source object.

keys

K[]

Array of keys to include.

Returns

Pick<T, K>

A new object with only the picked keys.

Example

const user = { id: 1, name: "Alice", email: "a@b.com" };
usePick(user, ["id", "name"]); // { id: 1, name: "Alice" }