import { TIME_UNITS } from '../constants' ; export const deserializeTime = ( time ) => { const timeUnits = Object . values ( TIME_UNITS ) ; const timeUnit = timeUnits . find ( ( unit ) => { const unitIndex = time . indexOf ( unit ) ; return unitIndex !== - 1 && unitIndex === time . length - 1 ; } ) ; if ( timeUnit ) { const timeValue = Number ( time . replace ( timeUnit , '' ) ) ; if ( ! isNaN ( timeValue ) ) { return { timeValue , timeUnit , } ; } } return { } ; } ; export const serializeTime = ( timeValue , timeUnit ) => { return `${ timeValue }${ timeUnit }` ; } ;