UNPKG

@telsystems/inputs

Version:
16 lines 699 B
import StringMask from 'string-mask'; export function fractionFormatter(value, count, needRestDigits) { var formatter = new StringMask('0'.repeat(count)); var formatedValue = formatter.apply(value); if (needRestDigits) { formatedValue += '0'.repeat(count - formatedValue.length); } return formatedValue; } export function integerFormatter(value, integerMask, integerMaskParams) { var formatter = new StringMask(integerMask, integerMaskParams); var valueInt = parseInt(value, 10); valueInt = isNaN(valueInt) ? 0 : valueInt; return valueInt < 0 ? '-' + formatter.apply(value) : formatter.apply(value); } //# sourceMappingURL=formatters.js.map