sahab-utils 1.2.9 → 1.3.0

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,3 +1,3 @@
1
- export declare function preventNaN(x?: number | string): number;
2
- export declare const toFixed: (num: any) => string;
3
- export declare const isEmpty: (text: any) => boolean;
1
+ export declare function preventNaN(x?: number | string): number;
2
+ export declare const toFixed: (num: any) => string;
3
+ export declare const isEmpty: (text: any) => boolean;
package/dist/ts/utils.js CHANGED
@@ -1,24 +1,24 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.isEmpty = exports.toFixed = void 0;
4
- exports.preventNaN = preventNaN;
5
- function preventNaN(x) {
6
- if (x === undefined || x === null || isNaN(x)) {
7
- return 0;
8
- }
9
- return Number(x);
10
- }
11
- const toFixed = (num) => {
12
- const decimal_places = 2;
13
- num = Number(num || 0);
14
- return (Math.round(num * 10 ** decimal_places) / 10 ** decimal_places).toFixed(decimal_places);
15
- };
16
- exports.toFixed = toFixed;
17
- const isEmpty = (text) => {
18
- const txt = typeof text === 'string' ? text.trim() : text;
19
- if ((txt !== 0 && !txt) || txt === '' || txt === null || txt === 'null' || txt === ' ' || txt === undefined || txt === 'undefined') {
20
- return true;
21
- }
22
- return false;
23
- };
24
- exports.isEmpty = isEmpty;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isEmpty = exports.toFixed = void 0;
4
+ exports.preventNaN = preventNaN;
5
+ function preventNaN(x) {
6
+ if (x === undefined || x === null || isNaN(x)) {
7
+ return 0;
8
+ }
9
+ return Number(x);
10
+ }
11
+ const toFixed = (num) => {
12
+ const decimal_places = 2;
13
+ num = Number(num || 0);
14
+ return (Math.round(num * 10 ** decimal_places) / 10 ** decimal_places).toFixed(decimal_places);
15
+ };
16
+ exports.toFixed = toFixed;
17
+ const isEmpty = (text) => {
18
+ const txt = typeof text === 'string' ? text.trim() : text;
19
+ if ((txt !== 0 && !txt) || txt === '' || txt === null || txt === 'null' || txt === ' ' || txt === undefined || txt === 'undefined') {
20
+ return true;
21
+ }
22
+ return false;
23
+ };
24
+ exports.isEmpty = isEmpty;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sahab-utils",
3
- "version": "1.2.9",
3
+ "version": "1.3.0",
4
4
  "description": "This package contains types and utils functions",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",