@thainanluiz/tssuper 0.0.2 → 0.0.4
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/CHANGELOG.md +4 -0
- package/FUNCTIONS.md +1 -1
- package/dist/index.d.mts +12 -1
- package/dist/index.d.ts +12 -1
- package/dist/index.js +18 -3
- package/dist/index.mjs +23 -2
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
package/FUNCTIONS.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
## 0.0.1
|
|
4
4
|
|
|
5
|
-
- [randomInt](https://github.com/thainanluiz/
|
|
5
|
+
- [randomInt](https://github.com/thainanluiz/TSSuper/blob/main/examples/randomInt.ts)( {min: number, max: number } ) <br>
|
|
6
6
|
Will return a value between the maximum and minimum number.
|
|
7
7
|
|
|
8
8
|
<br>
|
package/dist/index.d.mts
CHANGED
|
@@ -3,6 +3,17 @@ type RandomIntProps = {
|
|
|
3
3
|
max: number;
|
|
4
4
|
};
|
|
5
5
|
|
|
6
|
+
/**
|
|
7
|
+
* Generate a random integer between min and max (inclusive)
|
|
8
|
+
* @param {RandomIntProps} { min, max }
|
|
9
|
+
* @returns {number}
|
|
10
|
+
*/
|
|
6
11
|
declare function randomInt({ min, max }: RandomIntProps): number;
|
|
7
12
|
|
|
8
|
-
|
|
13
|
+
type index_RandomIntProps = RandomIntProps;
|
|
14
|
+
declare const index_randomInt: typeof randomInt;
|
|
15
|
+
declare namespace index {
|
|
16
|
+
export { type index_RandomIntProps as RandomIntProps, index_randomInt as randomInt };
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export { index as math };
|
package/dist/index.d.ts
CHANGED
|
@@ -3,6 +3,17 @@ type RandomIntProps = {
|
|
|
3
3
|
max: number;
|
|
4
4
|
};
|
|
5
5
|
|
|
6
|
+
/**
|
|
7
|
+
* Generate a random integer between min and max (inclusive)
|
|
8
|
+
* @param {RandomIntProps} { min, max }
|
|
9
|
+
* @returns {number}
|
|
10
|
+
*/
|
|
6
11
|
declare function randomInt({ min, max }: RandomIntProps): number;
|
|
7
12
|
|
|
8
|
-
|
|
13
|
+
type index_RandomIntProps = RandomIntProps;
|
|
14
|
+
declare const index_randomInt: typeof randomInt;
|
|
15
|
+
declare namespace index {
|
|
16
|
+
export { type index_RandomIntProps as RandomIntProps, index_randomInt as randomInt };
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export { index as math };
|
package/dist/index.js
CHANGED
|
@@ -20,15 +20,30 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
20
20
|
// src/index.ts
|
|
21
21
|
var src_exports = {};
|
|
22
22
|
__export(src_exports, {
|
|
23
|
-
|
|
23
|
+
math: () => math_exports
|
|
24
24
|
});
|
|
25
25
|
module.exports = __toCommonJS(src_exports);
|
|
26
26
|
|
|
27
|
-
// src/
|
|
27
|
+
// src/math/index.ts
|
|
28
|
+
var math_exports = {};
|
|
29
|
+
__export(math_exports, {
|
|
30
|
+
randomInt: () => randomInt
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
// src/math/functions/randomInt.ts
|
|
28
34
|
function randomInt({ min, max }) {
|
|
35
|
+
if (typeof min !== "number" || typeof max !== "number") {
|
|
36
|
+
throw new Error("min and max must be numbers");
|
|
37
|
+
}
|
|
38
|
+
if (!Number.isInteger(min) || !Number.isInteger(max)) {
|
|
39
|
+
throw new Error("min and max must be integers");
|
|
40
|
+
}
|
|
41
|
+
if (min > max) {
|
|
42
|
+
throw new Error("min must be less than or equal to max");
|
|
43
|
+
}
|
|
29
44
|
return Math.floor(Math.random() * (max - min + 1)) + min;
|
|
30
45
|
}
|
|
31
46
|
// Annotate the CommonJS export names for ESM import in node:
|
|
32
47
|
0 && (module.exports = {
|
|
33
|
-
|
|
48
|
+
math
|
|
34
49
|
});
|
package/dist/index.mjs
CHANGED
|
@@ -1,7 +1,28 @@
|
|
|
1
|
-
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __export = (target, all) => {
|
|
3
|
+
for (var name in all)
|
|
4
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
5
|
+
};
|
|
6
|
+
|
|
7
|
+
// src/math/index.ts
|
|
8
|
+
var math_exports = {};
|
|
9
|
+
__export(math_exports, {
|
|
10
|
+
randomInt: () => randomInt
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
// src/math/functions/randomInt.ts
|
|
2
14
|
function randomInt({ min, max }) {
|
|
15
|
+
if (typeof min !== "number" || typeof max !== "number") {
|
|
16
|
+
throw new Error("min and max must be numbers");
|
|
17
|
+
}
|
|
18
|
+
if (!Number.isInteger(min) || !Number.isInteger(max)) {
|
|
19
|
+
throw new Error("min and max must be integers");
|
|
20
|
+
}
|
|
21
|
+
if (min > max) {
|
|
22
|
+
throw new Error("min must be less than or equal to max");
|
|
23
|
+
}
|
|
3
24
|
return Math.floor(Math.random() * (max - min + 1)) + min;
|
|
4
25
|
}
|
|
5
26
|
export {
|
|
6
|
-
|
|
27
|
+
math_exports as math
|
|
7
28
|
};
|