UNPKG

@tractorzoom/equipment-attributes

Version:

Source of truth for equipment attributes by category

19 lines (18 loc) 625 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.formatNumberWithThousandSeparator = void 0; const formatNumberWithThousandSeparator = (value, skip = false) => { if (!value && !skip) { return '---'; } if (Number.isNaN(Number(value))) { return value; } const valueString = Number(value).toFixed(2); return valueString .replace(/(\d)(?=(\d{3})+(?!\d))/g, '$1,') .replace(/(\..*)0$/, '$1') .replace(/(\..*)0$/, '$1') .replace(/\.$/, ''); }; exports.formatNumberWithThousandSeparator = formatNumberWithThousandSeparator;