@tb-dev/utils 1.0.8 → 1.0.9

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/index.cjs CHANGED
@@ -12,7 +12,14 @@ function isEmpty(value) {
12
12
  return true;
13
13
  }
14
14
  function repeat(amount, fn) {
15
- for (let i = 0; i < amount; i++) {
15
+ let n = Math.trunc(amount);
16
+ if (n < 1) {
17
+ n = 0;
18
+ }
19
+ else if (n > Number.MAX_SAFE_INTEGER) {
20
+ n = Number.MAX_SAFE_INTEGER;
21
+ }
22
+ for (let i = 0; i < n; i++) {
16
23
  fn(i);
17
24
  }
18
25
  }
package/dist/index.mjs CHANGED
@@ -8,7 +8,14 @@ function isEmpty(value) {
8
8
  return true;
9
9
  }
10
10
  function repeat(amount, fn) {
11
- for (let i = 0; i < amount; i++) {
11
+ let n = Math.trunc(amount);
12
+ if (n < 1) {
13
+ n = 0;
14
+ }
15
+ else if (n > Number.MAX_SAFE_INTEGER) {
16
+ n = Number.MAX_SAFE_INTEGER;
17
+ }
18
+ for (let i = 0; i < n; i++) {
12
19
  fn(i);
13
20
  }
14
21
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tb-dev/utils",
3
- "version": "1.0.8",
3
+ "version": "1.0.9",
4
4
  "description": "TypeScript utils",
5
5
  "license": "MIT",
6
6
  "type": "module",