merge method
Merges the map in others
with the current map.
If the same key is found, the value of others
has priority.
Implementation
Map<K, V> merge(
Map<K, V>? others, {
K Function(K key)? convertKeys,
V Function(V value)? convertValues,
}) {
others ??= const {};
final res = <K, V>{};
for (final tmp in entries) {
res[tmp.key] = tmp.value;
}
for (final tmp in others.entries) {
final key = convertKeys?.call(tmp.key) ?? tmp.key;
final value = convertValues?.call(tmp.value) ?? tmp.value;
res[key] = value;
}
return res;
}