ismx-nexo-node-app 0.4.142 → 0.4.144

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.
@@ -94,6 +94,8 @@ class ColorUtils {
94
94
  return color + alphaHex;
95
95
  }
96
96
  static isColor(color) {
97
+ if (!color || typeof color !== 'string')
98
+ return false;
97
99
  return /^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/.test(color);
98
100
  }
99
101
  }
@@ -5,8 +5,11 @@ class NumberUtils {
5
5
  return Math.floor(Math.random() * (upper + 1 - lower)) + lower;
6
6
  }
7
7
  static duration(seconds) {
8
- const mins = Math.floor(seconds / 60);
9
- const secs = seconds % 60;
8
+ if (seconds == null)
9
+ return null;
10
+ const truncated = Math.trunc(seconds + 1);
11
+ const mins = Math.floor(truncated / 60);
12
+ const secs = truncated % 60;
10
13
  const minsStr = mins.toString().padStart(2, '0');
11
14
  const secsStr = secs.toString().padStart(2, '0');
12
15
  return `${minsStr}:${secsStr}`;
@@ -1,4 +1,5 @@
1
1
  export default abstract class NumberUtils {
2
2
  static random(lower: number, upper: number): number;
3
3
  static duration(seconds: number): string;
4
+ static duration(seconds: null | undefined): null;
4
5
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ismx-nexo-node-app",
3
- "version": "0.4.142",
3
+ "version": "0.4.144",
4
4
  "description": "",
5
5
  "scripts": {
6
6
  "build": "rm -rf ./dist && npx tsc",
@@ -87,6 +87,7 @@ export default abstract class ColorUtils {
87
87
  }
88
88
 
89
89
  static isColor(color: string): boolean {
90
+ if (!color || typeof color !== 'string') return false;
90
91
  return /^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/.test(color);
91
92
  }
92
93
  }
@@ -4,9 +4,13 @@ export default abstract class NumberUtils {
4
4
  return Math.floor(Math.random() * (upper + 1 - lower)) + lower;
5
5
  }
6
6
 
7
- static duration(seconds: number): string {
8
- const mins = Math.floor(seconds / 60);
9
- const secs = seconds % 60;
7
+ static duration(seconds: number): string;
8
+ static duration(seconds: null | undefined): null;
9
+ static duration(seconds: number | null | undefined): string | null {
10
+ if (seconds == null) return null;
11
+ const truncated = Math.trunc(seconds+1);
12
+ const mins = Math.floor(truncated / 60);
13
+ const secs = truncated % 60;
10
14
  const minsStr = mins.toString().padStart(2, '0');
11
15
  const secsStr = secs.toString().padStart(2, '0');
12
16
  return `${minsStr}:${secsStr}`;