import { Duration , DateInput } from './types' ; import { ZERO , UNITS_META } from './lib/units' ; example export const between = ( date1 , date2 ) : Duration => { const a = new Date ( date1 ) ; const b = new Date ( date2 ) ; const output = { ... ZERO } ; UNITS_META . forEach ( ( { unit , dateGetter } ) => { output [ unit ] = dateGetter ( b ) - dateGetter ( a ) ; } ) ; return output ; } ;