UNPKG

es-next-tools

Version:

A comprehensive utility library for JavaScript and TypeScript that provides a wide range of functions for common programming tasks, including mathematical operations, date manipulations, array and object handling, string utilities, and more.

13 lines (12 loc) 784 B
/** * Creates an object composed of the picked object properties. * @param {T} object - The source object. * @param {K[] | ((key: string, value: T[K]) => boolean)} keysOrPredicate - An array of property names to pick or a predicate function. * @returns A new object with the picked properties. * @example * const obj = { a: 1, b: 2, c: 3, d: 4 }; * const picked1 = pick(obj, ['a', 'c']); // { a: 1, c: 3 } * const picked2 = pick(obj, (key, value) => value % 2 === 0); // { b: 2, d: 4 } */ export declare function pick<T extends Record<string, any>, K extends keyof T>(object: T, keysOrPredicate: K[]): Omit<T, K>; export declare function pick<T extends Record<string, any>, K extends keyof T>(object: T, keysOrPredicate: ((key: string, value: T[K]) => boolean)): Partial<T>;