UNPKG

bootstrap-vue

Version:

With more than 85 components, over 45 available plugins, several directives, and 1000+ icons, BootstrapVue provides one of the most comprehensive implementations of the Bootstrap v4 component and grid system available for Vue.js v2.6, complete with extens

20 lines (18 loc) 914 B
// Number utilities // Converts a value (string, number, etc.) to an integer number // Assumes radix base 10 export var toInteger = function toInteger(value) { var defaultValue = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : NaN; var integer = parseInt(value, 10); return isNaN(integer) ? defaultValue : integer; }; // Converts a value (string, number, etc.) to a number export var toFloat = function toFloat(value) { var defaultValue = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : NaN; var float = parseFloat(value); return isNaN(float) ? defaultValue : float; }; // Converts a value (string, number, etc.) to a string // representation with `precision` digits after the decimal // Returns the string 'NaN' if the value cannot be converted export var toFixed = function toFixed(val, precision) { return toFloat(val).toFixed(toInteger(precision, 0)); };