All files / src/lib cleanDurationObject.ts

100% Statements 8/8
100% Branches 1/1
100% Functions 2/2
100% Lines 7/7

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 1615x     15x 439x   439x   3512x 2862x       439x    
import { UNITS } from './units';
import { Duration } from '../types';
 
export const cleanDurationObject = (duration: Readonly<Duration>): Readonly<Duration> => {
	const output = { ...duration };
 
	UNITS.forEach(key => {
		// Convert `-0` to `0`. Both values will evaluate as `true` here.
		if (output[key] === 0) {
			output[key] = 0;
		}
	});
 
	return output;
};