@baseplate-dev/sync
Version:
Library for syncing Baseplate descriptions
22 lines • 946 B
TypeScript
/**
* Merges a variable number of `Map` instances or arrays of entries (`[key, value]`)
* into a single `Map`. Throws an error if duplicate keys are found.
*
* @param {...(Map | [key, value][])[]} maps - A variable number of `Map` instances or arrays of entries to merge.
* @returns {Map} - A new `Map` containing the merged entries.
* @throws {Error} If a duplicate key is found across the provided maps.
*
* @example
* const map1 = new Map([['a', 1]]);
* const map2 = new Map([['b', 2]]);
* const arrayEntries = [['c', 3]];
* const result = safeMergeMap(map1, map2, arrayEntries);
* // Result: Map { 'a' => 1, 'b' => 2, 'c' => 3 }
*
* @example
* const map1 = new Map([['a', 1]]);
* const map2 = new Map([['a', 2]]);
* safeMergeMap(map1, map2); // Throws Error: Duplicate key found during merge: a
*/
export declare function safeMergeMap<K, V>(...maps: (Map<K, V> | [K, V][])[]): Map<K, V>;
//# sourceMappingURL=merge.d.ts.map