fd22b0bf58
V2 (Laravel re-make)
23 lines
742 B
JavaScript
Vendored
23 lines
742 B
JavaScript
Vendored
var plugin = {
|
|
level1: {
|
|
value: function precision(_name, value, options) {
|
|
if (!options.precision.enabled || value.indexOf('.') === -1) {
|
|
return value;
|
|
}
|
|
|
|
return value
|
|
.replace(options.precision.decimalPointMatcher, '$1$2$3')
|
|
.replace(options.precision.zeroMatcher, function (match, integerPart, fractionPart, unit) {
|
|
var multiplier = options.precision.units[unit].multiplier;
|
|
var parsedInteger = parseInt(integerPart);
|
|
var integer = isNaN(parsedInteger) ? 0 : parsedInteger;
|
|
var fraction = parseFloat(fractionPart);
|
|
|
|
return Math.round((integer + fraction) * multiplier) / multiplier + unit;
|
|
});
|
|
}
|
|
}
|
|
};
|
|
|
|
module.exports = plugin;
|