|
Last change
on this file was a762898, checked in by istevanoska <ilinastevanoska@…>, 5 months ago |
|
Added visualizations
|
-
Property mode
set to
100644
|
|
File size:
766 bytes
|
| Rev | Line | |
|---|
| [a762898] | 1 | /**
|
|---|
| 2 | * Creates a new object composed of the picked object properties.
|
|---|
| 3 | *
|
|---|
| 4 | * This function takes an object and an array of keys, and returns a new object that
|
|---|
| 5 | * includes only the properties corresponding to the specified keys.
|
|---|
| 6 | *
|
|---|
| 7 | * @template T - The type of object.
|
|---|
| 8 | * @template K - The type of keys in object.
|
|---|
| 9 | * @param {T} obj - The object to pick keys from.
|
|---|
| 10 | * @param {K[]} keys - An array of keys to be picked from the object.
|
|---|
| 11 | * @returns {Pick<T, K>} 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 Record<string, any>, K extends keyof T>(obj: T, keys: readonly K[]): Pick<T, K>;
|
|---|
| 19 |
|
|---|
| 20 | export { pick };
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.