import { assert } from "../../assert.js";

/**
 *
 * @param {number} x
 * @param {string} [separator=',']
 * @returns {string}
 */
export function number_format_by_thousands(x, separator = ',') {
    assert.isNumber(x, 'x');
    assert.isString(separator, 'separator');

    return x.toString().replace(/\B(?=(\d{3})+(?!\d))/g, separator);
}
