@lichens-innovation/ts-common 1.2.1 → 1.2.2

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.
@@ -1,2 +1,4 @@
1
1
  export declare const toFixed: (value?: number | null, decimals?: number) => number;
2
+ export declare const roundUpToNearest10: (value?: number | null) => number;
3
+ export declare const getOrderOfMagnitudeExponent: (n?: number | null) => number;
2
4
  //# sourceMappingURL=number.utils.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"number.utils.d.ts","sourceRoot":"","sources":["../../src/utils/number.utils.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,OAAO,GAAI,QAAQ,MAAM,GAAG,IAAI,EAAE,iBAAY,KAAG,MAO7D,CAAC"}
1
+ {"version":3,"file":"number.utils.d.ts","sourceRoot":"","sources":["../../src/utils/number.utils.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,OAAO,GAAI,QAAQ,MAAM,GAAG,IAAI,EAAE,iBAAY,KAAG,MAO7D,CAAC;AAEF,eAAO,MAAM,kBAAkB,GAAI,QAAQ,MAAM,GAAG,IAAI,KAAG,MAG1D,CAAC;AAEF,eAAO,MAAM,2BAA2B,GAAI,IAAI,MAAM,GAAG,IAAI,KAAG,MAW/D,CAAA"}
@@ -1,4 +1,4 @@
1
- import { isNullish } from "./types.utils";
1
+ import { isNullish, isNumber } from "./types.utils";
2
2
  // Example: toFixed(3.14159, 3) // 3.142
3
3
  export const toFixed = (value, decimals = 0) => {
4
4
  if (isNullish(value))
@@ -10,4 +10,21 @@ export const toFixed = (value, decimals = 0) => {
10
10
  const multiplier = Math.pow(10, decimals);
11
11
  return Math.round(value * multiplier) / multiplier;
12
12
  };
13
+ export const roundUpToNearest10 = (value) => {
14
+ if (isNullish(value))
15
+ return 0;
16
+ return Math.ceil(value / 10) * 10;
17
+ };
18
+ export const getOrderOfMagnitudeExponent = (n) => {
19
+ if (isNullish(n))
20
+ return 0;
21
+ if (!isNumber(n))
22
+ return 0;
23
+ const absValue = Math.abs(n);
24
+ if (absValue === 0) {
25
+ return 0;
26
+ }
27
+ const integerPart = Math.floor(absValue);
28
+ return Math.floor(Math.log10(integerPart));
29
+ };
13
30
  //# sourceMappingURL=number.utils.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"number.utils.js","sourceRoot":"","sources":["../../src/utils/number.utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAE1C,wCAAwC;AACxC,MAAM,CAAC,MAAM,OAAO,GAAG,CAAC,KAAqB,EAAE,QAAQ,GAAG,CAAC,EAAU,EAAE;IACrE,IAAI,SAAS,CAAC,KAAK,CAAC;QAAE,OAAO,CAAC,CAAC;IAC/B,IAAI,QAAQ,GAAG,CAAC;QAAE,MAAM,IAAI,KAAK,CAAC,iCAAiC,CAAC,CAAC;IACrE,IAAI,QAAQ,KAAK,CAAC;QAAE,OAAO,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;IAE7C,MAAM,UAAU,GAAG,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE,QAAQ,CAAC,CAAC;IAC1C,OAAO,IAAI,CAAC,KAAK,CAAC,KAAK,GAAG,UAAU,CAAC,GAAG,UAAU,CAAC;AACrD,CAAC,CAAC"}
1
+ {"version":3,"file":"number.utils.js","sourceRoot":"","sources":["../../src/utils/number.utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAEpD,wCAAwC;AACxC,MAAM,CAAC,MAAM,OAAO,GAAG,CAAC,KAAqB,EAAE,QAAQ,GAAG,CAAC,EAAU,EAAE;IACrE,IAAI,SAAS,CAAC,KAAK,CAAC;QAAE,OAAO,CAAC,CAAC;IAC/B,IAAI,QAAQ,GAAG,CAAC;QAAE,MAAM,IAAI,KAAK,CAAC,iCAAiC,CAAC,CAAC;IACrE,IAAI,QAAQ,KAAK,CAAC;QAAE,OAAO,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;IAE7C,MAAM,UAAU,GAAG,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE,QAAQ,CAAC,CAAC;IAC1C,OAAO,IAAI,CAAC,KAAK,CAAC,KAAK,GAAG,UAAU,CAAC,GAAG,UAAU,CAAC;AACrD,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,KAAqB,EAAU,EAAE;IAClE,IAAI,SAAS,CAAC,KAAK,CAAC;QAAE,OAAO,CAAC,CAAC;IAC/B,OAAO,IAAI,CAAC,IAAI,CAAC,KAAK,GAAG,EAAE,CAAC,GAAG,EAAE,CAAC;AACpC,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,2BAA2B,GAAG,CAAC,CAAiB,EAAU,EAAE;IACvE,IAAI,SAAS,CAAC,CAAC,CAAC;QAAE,OAAO,CAAC,CAAC;IAC3B,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC;QAAE,OAAO,CAAC,CAAC;IAE3B,MAAM,QAAQ,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;IAC7B,IAAI,QAAQ,KAAK,CAAC,EAAE,CAAC;QACnB,OAAO,CAAC,CAAC;IACX,CAAC;IAED,MAAM,WAAW,GAAG,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;IACzC,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC,CAAC;AAC7C,CAAC,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lichens-innovation/ts-common",
3
- "version": "1.2.1",
3
+ "version": "1.2.2",
4
4
  "description": "Reusable generic typescript utilities, types, constants, helpers",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -11,6 +11,10 @@
11
11
  "author": "Lichens Innovation",
12
12
  "license": "MIT",
13
13
  "type": "module",
14
+ "publishConfig": {
15
+ "access": "public",
16
+ "registry": "https://registry.npmjs.org/"
17
+ },
14
18
  "scripts": {
15
19
  "clean:node": "npx rimraf node_modules yarn.lock",
16
20
  "clean:dist": "npx rimraf dist",