export interface AmountAndUnit { amount : number ; unit : string ; } export function amountAndUnitToObject ( value ) { const [ , amount = '' , unit = '' ] = value . match ( /(^-?\d+)?(\w+)?/ ) || [ ] ; return { amount : parseInt ( amount , 10 ) , unit } ; } export function amountAndUnitToString ( { amount , unit , } ) { return `${ amount }${ unit }` ; }