import { BasicArithmetic } from '../arithmetic' export const add = (arithmetic: BasicArithmetic) => (a: Map, b: Map) => { const result = new Map(a) // clone `a` to `result` for (const [key, bValue] of b) { const aValue = result.get(key) if (aValue !== undefined) { result.set(key, arithmetic.add(aValue, bValue)) } else { result.set(key, bValue) } } return result }