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 | 2x 2x 77x 17x 17x 37x 296x 14x | import { Duration, DurationInput } from './types';
import { UNITS, ZERO } from './lib/units';
import { parse } from './parse';
/**
* Sum durations.
*
* @example
* sum({ days: 1 }, { days: 2, hours: 12 })
* { days: 3, hours: 12 }
*/
export const sum = (...durations: DurationInput[]): Duration => {
const output = { ...ZERO };
durations.map(parse).forEach(duration => {
UNITS.forEach(key => {
output[key] += duration[key];
});
});
return output;
};
|