/**
 * @dyna-grid/core - Advanced Data Grid / Data Table supporting Javascript / Web Components
 * @version v1.0.5
 * @link 
 * @license 
 */
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
function padStart(value, totalStringSize) {
    var asString = "" + value;
    while (asString.length < totalStringSize) {
        asString = "0" + asString;
    }
    return asString;
}
exports.padStart = padStart;
function createArrayOfNumbers(first, last) {
    var result = [];
    for (var i = first; i <= last; i++) {
        result.push(i);
    }
    return result;
}
exports.createArrayOfNumbers = createArrayOfNumbers;
/**
 * Check if a value is numeric
 * from http://stackoverflow.com/questions/9716468/is-there-any-function-like-isnumeric-in-javascript-to-validate-numbers
 * @param {any} value
 * @return {boolean}
 */
function isNumeric(value) {
    return value !== '' && !isNaN(parseFloat(value)) && isFinite(value);
}
exports.isNumeric = isNumeric;
function getMaxSafeInteger() {
    // eslint-disable-next-line
    return Number.MAX_SAFE_INTEGER || 9007199254740991;
}
exports.getMaxSafeInteger = getMaxSafeInteger;
function cleanNumber(value) {
    if (typeof value === 'string') {
        value = parseInt(value, 10);
    }
    if (typeof value === 'number') {
        return Math.floor(value);
    }
    return null;
}
exports.cleanNumber = cleanNumber;
function decToHex(number, bytes) {
    var hex = '';
    for (var i = 0; i < bytes; i++) {
        hex += String.fromCharCode(number & 0xff);
        number >>>= 8;
    }
    return hex;
}
exports.decToHex = decToHex;
function formatNumberTwoDecimalPlacesAndCommas(value) {
    if (typeof value !== 'number') {
        return '';
    }
    return formatNumberCommas(Math.round(value * 100) / 100);
}
exports.formatNumberTwoDecimalPlacesAndCommas = formatNumberTwoDecimalPlacesAndCommas;
/**
 * the native method number.toLocaleString(undefined, {minimumFractionDigits: 0})
 * puts in decimal places in IE, so we use this method instead
 * from: http://blog.tompawlak.org/number-currency-formatting-javascript
 * @param {number} value
 * @returns {string}
 */
function formatNumberCommas(value) {
    if (typeof value !== 'number') {
        return '';
    }
    return value.toString().replace(/(\d)(?=(\d{3})+(?!\d))/g, "$1,");
}
exports.formatNumberCommas = formatNumberCommas;
function sum(values) {
    return values == null ? null : values.reduce(function (total, value) { return total + value; }, 0);
}
exports.sum = sum;

//# sourceMappingURL=number.js.map
