|
Last change
on this file since a762898 was a762898, checked in by istevanoska <ilinastevanoska@…>, 5 months ago |
|
Added visualizations
|
-
Property mode
set to
100644
|
|
File size:
929 bytes
|
| Line | |
|---|
| 1 | /**
|
|---|
| 2 | * Creates a new object with the same values as the given object, but with keys generated
|
|---|
| 3 | * by running each own enumerable property of the object through the iteratee function.
|
|---|
| 4 | *
|
|---|
| 5 | * @template T - The type of the object.
|
|---|
| 6 | * @template K - The type of the new keys generated by the iteratee function.
|
|---|
| 7 | *
|
|---|
| 8 | * @param {T} object - The object to iterate over.
|
|---|
| 9 | * @param {(value: T[keyof T], key: keyof T, object: T) => K} getNewKey - The function invoked per own enumerable property.
|
|---|
| 10 | * @returns {Record<K, T[keyof T]>} - Returns the new mapped object.
|
|---|
| 11 | *
|
|---|
| 12 | * @example
|
|---|
| 13 | * // Example usage:
|
|---|
| 14 | * const obj = { a: 1, b: 2 };
|
|---|
| 15 | * const result = mapKeys(obj, (value, key) => key + value);
|
|---|
| 16 | * console.log(result); // { a1: 1, b2: 2 }
|
|---|
| 17 | */
|
|---|
| 18 | declare function mapKeys<T extends Record<PropertyKey, any>, K extends PropertyKey>(object: T, getNewKey: (value: T[keyof T], key: keyof T, object: T) => K): Record<K, T[keyof T]>;
|
|---|
| 19 |
|
|---|
| 20 | export { mapKeys };
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.