@monstermann/fn
Version:
A utility library for TypeScript.
23 lines (21 loc) • 641 B
TypeScript
import { DistributedPick, KeysOfUnion } from "type-fest";
//#region src/object/pick.d.ts
/**
* `pick(target, keys)`
*
* Creates a new object containing only the properties specified in the `keys` iterable.
*
* ```ts
* pick({ a: 1, b: 2, c: 3 }, ["a", "c"]); // { a: 1, c: 3 }
* ```
*
* ```ts
* pipe({ a: 1, b: 2, c: 3 }, pick(["a", "c"])); // { a: 1, c: 3 }
* ```
*/
declare const pick: {
<T extends object, K extends KeysOfUnion<T>>(keys: Iterable<K>): (target: T) => DistributedPick<T, K>;
<T extends object, K extends KeysOfUnion<T>>(target: T, keys: Iterable<K>): DistributedPick<T, K>;
};
//#endregion
export { pick };