Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | 2x 2x | /**
* Copies all entries of a {@link Map} into a new {@link Map}
*
* @example
* Copy a {@link Map}
* ```ts
* const map = new Map([["A", "B"]]);
* const copiedMap = copy(map);
* console.log(copiedMap); // Map([["A", "B"]])
* console.log(map === copiedMap); // false
* ```
*
* @typeParam K - the {@link Map} key type
* @typeParam V - the {@link Map} value type
* @param map - the {@link Map} to copy
* @returns the new {@link Map} containing all entries of the source {@link Map}
*/
export const copy = <K, V>(map: Map<K, V>): Map<K, V> => {
return new Map(map);
};
|