@hestia-earth/utils 0.10.29 → 0.10.30

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/number.d.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  export declare const isNumber: (n: string | number) => boolean;
2
2
  export declare const toPrecision: (n: number, precision?: number) => number;
3
+ export declare const toComma: (n: number) => string;
3
4
  export declare enum ConvertUnits {
4
5
  m3 = "m3",
5
6
  kg = "kg",
package/dist/number.js CHANGED
@@ -1,7 +1,23 @@
1
1
  "use strict";
2
+ var __read = (this && this.__read) || function (o, n) {
3
+ var m = typeof Symbol === "function" && o[Symbol.iterator];
4
+ if (!m) return o;
5
+ var i = m.call(o), r, ar = [], e;
6
+ try {
7
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
8
+ }
9
+ catch (error) { e = { error: error }; }
10
+ finally {
11
+ try {
12
+ if (r && !r.done && (m = i["return"])) m.call(i);
13
+ }
14
+ finally { if (e) throw e.error; }
15
+ }
16
+ return ar;
17
+ };
2
18
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z;
3
19
  Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.convertValue = exports.converters = exports.ConvertUnits = exports.toPrecision = exports.isNumber = void 0;
20
+ exports.convertValue = exports.converters = exports.ConvertUnits = exports.toComma = exports.toPrecision = exports.isNumber = void 0;
5
21
  var isNumber = function (n) {
6
22
  var _a;
7
23
  return [
@@ -18,6 +34,12 @@ var toPrecision = function (n, precision) {
18
34
  return n === 0 ? 0 : Math.round(n * multiplier) / multiplier;
19
35
  };
20
36
  exports.toPrecision = toPrecision;
37
+ var toComma = function (n) {
38
+ var _a = __read(n.toString().split('.'), 2), numberPart = _a[0], decimalPart = _a[1];
39
+ var thousands = /\B(?=(\d{3})+(?!\d))/g;
40
+ return "" + numberPart.replace(thousands, ',') + (decimalPart ? "." + decimalPart : '');
41
+ };
42
+ exports.toComma = toComma;
21
43
  var C = 12.012;
22
44
  var CA = 40.078;
23
45
  var H = 1.008;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hestia-earth/utils",
3
- "version": "0.10.29",
3
+ "version": "0.10.30",
4
4
  "description": "Hestia Utils library",
5
5
  "main": "dist/index.js",
6
6
  "typings": "dist/index.d.ts",