import { toNumber } from 'lodash-es' ; import { StringOrNumber } from '../types' ; type LocaleType = 'zh-CN' | string ; export class NumberStore { private numberFormatter : Intl . NumberFormat ; constructor ( locale , options = { } ) { this . numberFormatter = new Intl . NumberFormat ( locale , options ) ; } parse ( value ) { if ( typeof value === 'number' ) { return value ; } const newValue = value . replace ( /,/g , '' ) ; return Number ( newValue ) ; } format ( value ) { const number = toNumber ( value ) ; const ret = this . numberFormatter . format ( number ) ; return ret ; } }