/**
 * @since Last modified: 2024/06/03 10:44:56
 * @function number
 * @description Format numbers or numeric strings”.
 * @param {string|number} data - numbers or numeric strings.
 * @param {object} [opt] - Parameters.
 * @returns {number}  - Formatted number.
 * @see {@link https://codepen.io/axui/pen/dyEvEQK|demo @ codepen}
 * @example
 * ax.number('23.6963')
 * <!--return 23.7-->
 */
'use strict';
const number = (data, opt) => {
    let options = Object.assign({ places: 2, mode: 'round', zero: false }, opt), result = 0;
    if (!data || !Number(data)) {
        return 0;
    }
    else {
        let number = Number(data), precise = number + Number.EPSILON, places = Number(`1${'0'.repeat(options.places)}`), tempNumber = number * places, tempPrecise = precise * places;
        if (options.mode === 'floor') {
            result = Math.floor(tempNumber) / places;
        }
        else if (options.mode === 'ceil') {
            result = Math.ceil(tempNumber) / places;
        }
        else {
            result = Math.round(tempPrecise) / places;
        }
    }
    if (options.zero) {
        result = +result.toFixed(options.places);
    }
    return result;
};
export default number;
