@putkoff/abstract-utilities 0.1.227 → 0.1.229

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cjs/index.js CHANGED
@@ -1114,6 +1114,25 @@ function getCleanArray(obj) {
1114
1114
  const uniqueWords = cleanArray(obj);
1115
1115
  return uniqueWords;
1116
1116
  }
1117
+ // Cache a formatter instance for slightly better performance
1118
+ const US_DECIMAL_FORMATTER = new Intl.NumberFormat('en-US', {
1119
+ minimumFractionDigits: 2,
1120
+ maximumFractionDigits: 2,
1121
+ });
1122
+ function formatNumber(value) {
1123
+ try {
1124
+ // coerce to number
1125
+ const num = Number(value);
1126
+ // if it's NaN or infinite, bail out
1127
+ if (!isFinite(num))
1128
+ return value;
1129
+ return US_DECIMAL_FORMATTER.format(num);
1130
+ }
1131
+ catch (_a) {
1132
+ // if anything goes wrong, return the original
1133
+ return value;
1134
+ }
1135
+ }
1117
1136
 
1118
1137
  // Constrain T so 'in obj' is allowed
1119
1138
  function get_key_value(obj, key) {
@@ -1712,6 +1731,7 @@ exports.ensure_string = ensure_string;
1712
1731
  exports.fetchIndexHtml = fetchIndexHtml;
1713
1732
  exports.fetchIndexHtmlContainer = fetchIndexHtmlContainer;
1714
1733
  exports.fetchIt = fetchIt;
1734
+ exports.formatNumber = formatNumber;
1715
1735
  exports.geAuthsUtilsDirectory = geAuthsUtilsDirectory;
1716
1736
  exports.geBackupsUtilsDirectory = geBackupsUtilsDirectory;
1717
1737
  exports.geConstantsUtilsDirectory = geConstantsUtilsDirectory;