fn
pick
v0.0.3testedReturns a partial copy of an object containing only the keys specified
Examples
ts
pick({ a: 1, b: 2, c: 3 }, 'a') // => { a: 1 }ts
pick({ a: 1, b: 2, c: 3 }, ['a', 'b']) // => { a: 1, b: 2 }Signature
ts
export function pick<Target extends object, Key extends keyof Target>(
target: Target,
keys: Arrayable<Key>,
): Pick<Target, Key>{ ... }Type Parameters
Targetextends objectKeyextends keyof TargetParameters
| Parameter | Type | Description |
|---|---|---|
target | Target | The object to pick keys from |
keys | Arrayable<Key> | The object to pick keys from |
Returns
Pick<Target, Key>The new object with the specified keys picked