angular-input-masks
Version:
Personalized input masks for AngularJS
20 lines (15 loc) • 496 B
JavaScript
function clearDelimitersAndLeadingZeros(value) {
if (value === '0') {
return '0';
}
var cleanValue = value.toString().replace(/^-/,'').replace(/^0*/, '');
return cleanValue.replace(/[^0-9]/g, '');
}
function prepareNumberToFormatter(value, decimals) {
return clearDelimitersAndLeadingZeros((parseFloat(value)).toFixed(decimals));
}
module.exports = {
clearDelimitersAndLeadingZeros: clearDelimitersAndLeadingZeros,
prepareNumberToFormatter: prepareNumberToFormatter
};
;