|
Last change
on this file was a762898, checked in by istevanoska <ilinastevanoska@…>, 5 months ago |
|
Added visualizations
|
-
Property mode
set to
100644
|
|
File size:
1.2 KB
|
| Line | |
|---|
| 1 | type PropertyName = string | number | symbol;
|
|---|
| 2 | type Many<T> = T | readonly T[];
|
|---|
| 3 | type PropertyPath = Many<PropertyName>;
|
|---|
| 4 | /**
|
|---|
| 5 | * Gets values at given paths from a dictionary or numeric dictionary.
|
|---|
| 6 | *
|
|---|
| 7 | * @template T - The type of the values in the dictionary.
|
|---|
| 8 | * @param {Record<string, T> | Record<number, T> | null | undefined} object - The dictionary to query.
|
|---|
| 9 | * @param {...PropertyPath[]} props - The property paths to get values for.
|
|---|
| 10 | * @returns {T[]} Returns an array of the picked values.
|
|---|
| 11 | *
|
|---|
| 12 | * @example
|
|---|
| 13 | * const object = { 'a': 1, 'b': 2, 'c': 3 };
|
|---|
| 14 | * at(object, 'a', 'c');
|
|---|
| 15 | * // => [1, 3]
|
|---|
| 16 | */
|
|---|
| 17 | declare function at<T>(object: Record<string, T> | Record<number, T> | null | undefined, ...props: PropertyPath[]): T[];
|
|---|
| 18 | /**
|
|---|
| 19 | * Gets values at given keys from an object.
|
|---|
| 20 | *
|
|---|
| 21 | * @template T - The type of the object.
|
|---|
| 22 | * @param {T | null | undefined} object - The object to query.
|
|---|
| 23 | * @param {...Array<Many<keyof T>>} props - The property keys to get values for.
|
|---|
| 24 | * @returns {Array<T[keyof T]>} Returns an array of the picked values.
|
|---|
| 25 | *
|
|---|
| 26 | * @example
|
|---|
| 27 | * const object = { 'a': 1, 'b': 2, 'c': 3 };
|
|---|
| 28 | * at(object, 'a', 'c');
|
|---|
| 29 | * // => [1, 3]
|
|---|
| 30 | */
|
|---|
| 31 | declare function at<T extends object>(object: T | null | undefined, ...props: Array<Many<keyof T>>): Array<T[keyof T]>;
|
|---|
| 32 |
|
|---|
| 33 | export { at };
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.