@thainanluiz/tssuper 0.0.6 → 0.0.7
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/README.md +2 -2
- package/dist/index.d.mts +24 -1
- package/dist/index.d.ts +24 -1
- package/dist/index.js +15 -0
- package/dist/index.mjs +15 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -11,7 +11,7 @@ How to install
|
|
|
11
11
|
npm i @thainanluiz/tssuper
|
|
12
12
|
```
|
|
13
13
|
|
|
14
|
-
Package available [here] | current stable version [1.0.0] | current version [0.0.
|
|
14
|
+
Package available [here] | current stable version [1.0.0] | current version [0.0.7]
|
|
15
15
|
|
|
16
16
|
<br>
|
|
17
17
|
|
|
@@ -29,7 +29,7 @@ The entire [changelog here] <br>
|
|
|
29
29
|
|
|
30
30
|
[here]: https://www.npmjs.com/package/@thainanluiz/tssuper
|
|
31
31
|
[1.0.0]: https://www.npmjs.com/package/@thainanluiz/tssuper/v/1.0.0
|
|
32
|
-
[0.0.
|
|
32
|
+
[0.0.7]: https://www.npmjs.com/package/@thainanluiz/tssuper/v/0.0.7
|
|
33
33
|
[functions]: https://github.com/thainanluiz/TSSuper/blob/main/FUNCTIONS.md
|
|
34
34
|
[examples]: https://github.com/thainanluiz/TSSuper/blob/main/examples/
|
|
35
35
|
[changelog here]: https://github.com/thainanluiz/TSSuper/blob/main/CHANGELOG.md
|
package/dist/index.d.mts
CHANGED
|
@@ -6,14 +6,37 @@ type RandomIntProps = {
|
|
|
6
6
|
/**
|
|
7
7
|
* Generate a random integer between min and max (inclusive)
|
|
8
8
|
* @param {RandomIntProps} { min, max }
|
|
9
|
+
*
|
|
9
10
|
* @returns {number}
|
|
11
|
+
*
|
|
12
|
+
* @throws {Error} min and max must be numbers
|
|
13
|
+
* @throws {Error} min and max must be integers
|
|
14
|
+
* @throws {Error} min must be less than or equal to max
|
|
10
15
|
*/
|
|
11
16
|
declare function randomInt({ min, max }: RandomIntProps): number;
|
|
12
17
|
|
|
18
|
+
type FormatNumberProps = {
|
|
19
|
+
number: number;
|
|
20
|
+
decimalPlaces: number;
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Format a number to a specific number of decimal places
|
|
25
|
+
* @param {FormatNumberProps} { number, decimalPlaces }
|
|
26
|
+
*
|
|
27
|
+
* @returns {number}
|
|
28
|
+
*
|
|
29
|
+
* @throws {Error} number must be a number
|
|
30
|
+
* @throws {Error} decimalPlaces must be an integer
|
|
31
|
+
*/
|
|
32
|
+
declare function formatNumber({ number, decimalPlaces, }: FormatNumberProps): number;
|
|
33
|
+
|
|
34
|
+
type index_FormatNumberProps = FormatNumberProps;
|
|
13
35
|
type index_RandomIntProps = RandomIntProps;
|
|
36
|
+
declare const index_formatNumber: typeof formatNumber;
|
|
14
37
|
declare const index_randomInt: typeof randomInt;
|
|
15
38
|
declare namespace index {
|
|
16
|
-
export { type index_RandomIntProps as RandomIntProps, index_randomInt as randomInt };
|
|
39
|
+
export { type index_FormatNumberProps as FormatNumberProps, type index_RandomIntProps as RandomIntProps, index_formatNumber as formatNumber, index_randomInt as randomInt };
|
|
17
40
|
}
|
|
18
41
|
|
|
19
42
|
export { index as math };
|
package/dist/index.d.ts
CHANGED
|
@@ -6,14 +6,37 @@ type RandomIntProps = {
|
|
|
6
6
|
/**
|
|
7
7
|
* Generate a random integer between min and max (inclusive)
|
|
8
8
|
* @param {RandomIntProps} { min, max }
|
|
9
|
+
*
|
|
9
10
|
* @returns {number}
|
|
11
|
+
*
|
|
12
|
+
* @throws {Error} min and max must be numbers
|
|
13
|
+
* @throws {Error} min and max must be integers
|
|
14
|
+
* @throws {Error} min must be less than or equal to max
|
|
10
15
|
*/
|
|
11
16
|
declare function randomInt({ min, max }: RandomIntProps): number;
|
|
12
17
|
|
|
18
|
+
type FormatNumberProps = {
|
|
19
|
+
number: number;
|
|
20
|
+
decimalPlaces: number;
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Format a number to a specific number of decimal places
|
|
25
|
+
* @param {FormatNumberProps} { number, decimalPlaces }
|
|
26
|
+
*
|
|
27
|
+
* @returns {number}
|
|
28
|
+
*
|
|
29
|
+
* @throws {Error} number must be a number
|
|
30
|
+
* @throws {Error} decimalPlaces must be an integer
|
|
31
|
+
*/
|
|
32
|
+
declare function formatNumber({ number, decimalPlaces, }: FormatNumberProps): number;
|
|
33
|
+
|
|
34
|
+
type index_FormatNumberProps = FormatNumberProps;
|
|
13
35
|
type index_RandomIntProps = RandomIntProps;
|
|
36
|
+
declare const index_formatNumber: typeof formatNumber;
|
|
14
37
|
declare const index_randomInt: typeof randomInt;
|
|
15
38
|
declare namespace index {
|
|
16
|
-
export { type index_RandomIntProps as RandomIntProps, index_randomInt as randomInt };
|
|
39
|
+
export { type index_FormatNumberProps as FormatNumberProps, type index_RandomIntProps as RandomIntProps, index_formatNumber as formatNumber, index_randomInt as randomInt };
|
|
17
40
|
}
|
|
18
41
|
|
|
19
42
|
export { index as math };
|
package/dist/index.js
CHANGED
|
@@ -27,6 +27,7 @@ module.exports = __toCommonJS(src_exports);
|
|
|
27
27
|
// src/math/index.ts
|
|
28
28
|
var math_exports = {};
|
|
29
29
|
__export(math_exports, {
|
|
30
|
+
formatNumber: () => formatNumber,
|
|
30
31
|
randomInt: () => randomInt
|
|
31
32
|
});
|
|
32
33
|
|
|
@@ -43,6 +44,20 @@ function randomInt({ min, max }) {
|
|
|
43
44
|
}
|
|
44
45
|
return Math.floor(Math.random() * (max - min + 1)) + min;
|
|
45
46
|
}
|
|
47
|
+
|
|
48
|
+
// src/math/functions/formatNumber.ts
|
|
49
|
+
function formatNumber({
|
|
50
|
+
number,
|
|
51
|
+
decimalPlaces
|
|
52
|
+
}) {
|
|
53
|
+
if (typeof number !== "number") {
|
|
54
|
+
throw new Error("number must be a number");
|
|
55
|
+
}
|
|
56
|
+
if (!Number.isInteger(decimalPlaces)) {
|
|
57
|
+
throw new Error("decimalPlaces must be an integer");
|
|
58
|
+
}
|
|
59
|
+
return Number(number.toFixed(decimalPlaces));
|
|
60
|
+
}
|
|
46
61
|
// Annotate the CommonJS export names for ESM import in node:
|
|
47
62
|
0 && (module.exports = {
|
|
48
63
|
math
|
package/dist/index.mjs
CHANGED
|
@@ -7,6 +7,7 @@ var __export = (target, all) => {
|
|
|
7
7
|
// src/math/index.ts
|
|
8
8
|
var math_exports = {};
|
|
9
9
|
__export(math_exports, {
|
|
10
|
+
formatNumber: () => formatNumber,
|
|
10
11
|
randomInt: () => randomInt
|
|
11
12
|
});
|
|
12
13
|
|
|
@@ -23,6 +24,20 @@ function randomInt({ min, max }) {
|
|
|
23
24
|
}
|
|
24
25
|
return Math.floor(Math.random() * (max - min + 1)) + min;
|
|
25
26
|
}
|
|
27
|
+
|
|
28
|
+
// src/math/functions/formatNumber.ts
|
|
29
|
+
function formatNumber({
|
|
30
|
+
number,
|
|
31
|
+
decimalPlaces
|
|
32
|
+
}) {
|
|
33
|
+
if (typeof number !== "number") {
|
|
34
|
+
throw new Error("number must be a number");
|
|
35
|
+
}
|
|
36
|
+
if (!Number.isInteger(decimalPlaces)) {
|
|
37
|
+
throw new Error("decimalPlaces must be an integer");
|
|
38
|
+
}
|
|
39
|
+
return Number(number.toFixed(decimalPlaces));
|
|
40
|
+
}
|
|
26
41
|
export {
|
|
27
42
|
math_exports as math
|
|
28
43
|
};
|