export function reduceOrNull(value: T[], accumulate: (acc: T, it: T) => T): T | null { if (value.length === 0) return null; let acc = value[0]; for (let i = 1; i < value.length; i++) { acc = accumulate(acc, value[i]); } return acc; }