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 22 23 24 25 26 | 138x 138x 149x 138x | /**
* Map utilities for deep copying and manipulation.
* Pure functions for working with Map collections.
*/
class MapUtils {
/**
* Deep copy a Map<string, Set<string>>.
* Creates new Map and new Set instances to ensure complete isolation.
* Accepts ReadonlyMap/ReadonlySet for flexibility with immutable sources.
*
* @param source - The source Map to copy (can be readonly)
* @returns A new mutable Map with cloned Set values
*/
static deepCopyStringSetMap(
source: ReadonlyMap<string, ReadonlySet<string>>,
): Map<string, Set<string>> {
const copy = new Map<string, Set<string>>();
for (const [key, value] of source) {
copy.set(key, new Set(value));
}
return copy;
}
}
export default MapUtils;
|