| 1 | import { Many } from '../_internal/Many.js';
|
|---|
| 2 | import { PropertyPath } from '../_internal/PropertyPath.js';
|
|---|
| 3 |
|
|---|
| 4 | /**
|
|---|
| 5 | * Creates a new object composed of the picked object properties.
|
|---|
| 6 | *
|
|---|
| 7 | * @template T - The type of object.
|
|---|
| 8 | * @template U - The type of keys to pick.
|
|---|
| 9 | * @param {T} object - The object to pick keys from.
|
|---|
| 10 | * @param {...Array<Many<U>>} props - An array of keys to be picked from the object.
|
|---|
| 11 | * @returns {Pick<T, U>} A new object with the specified keys picked.
|
|---|
| 12 | *
|
|---|
| 13 | * @example
|
|---|
| 14 | * const obj = { a: 1, b: 2, c: 3 };
|
|---|
| 15 | * const result = pick(obj, ['a', 'c']);
|
|---|
| 16 | * // result will be { a: 1, c: 3 }
|
|---|
| 17 | */
|
|---|
| 18 | declare function pick<T extends object, U extends keyof T>(object: T, ...props: Array<Many<U>>): Pick<T, U>;
|
|---|
| 19 | /**
|
|---|
| 20 | * Creates a new object composed of the picked object properties.
|
|---|
| 21 | *
|
|---|
| 22 | * @template T - The type of object.
|
|---|
| 23 | * @param {T | null | undefined} object - The object to pick keys from.
|
|---|
| 24 | * @param {...Array<Many<PropertyPath>>} props - An array of keys to be picked from the object.
|
|---|
| 25 | * @returns {Partial<T>} A new object with the specified keys picked.
|
|---|
| 26 | *
|
|---|
| 27 | * @example
|
|---|
| 28 | * const obj = { a: 1, b: 2, c: 3 };
|
|---|
| 29 | * const result = pick(obj, ['a', 'c']);
|
|---|
| 30 | * // result will be { a: 1, c: 3 }
|
|---|
| 31 | */
|
|---|
| 32 | declare function pick<T>(object: T | null | undefined, ...props: Array<Many<PropertyPath>>): Partial<T>;
|
|---|
| 33 |
|
|---|
| 34 | export { pick };
|
|---|