@thainanluiz/tssuper 0.0.5 → 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/CHANGELOG.md CHANGED
@@ -1,21 +1,55 @@
1
1
  # Changelog
2
2
 
3
- TSSUPER project updates.
3
+ This document summarizes the updates and changes made to the TSSUPER project.
4
4
 
5
- ## [0.0.2] - 15/06/2024 - by [@thainanluiz].
5
+ ---
6
6
 
7
- ### Package renamed from "TSSuper" to "@thainanluiz/tssuper"
7
+ ## [0.0.6] - 2024-06-15
8
8
 
9
- ## [0.0.1] - 15/06/2024 - by [@thainanluiz].
9
+ ### Added
10
+
11
+ - **formatNumber function**:
12
+ - Formats a number to a specified number of decimal places.
13
+
14
+ ### Links
15
+
16
+ - [Version 0.0.6 on npm](https://www.npmjs.com/package/@thainanluiz/tssuper/v/0.0.6)
17
+
18
+ ---
19
+
20
+ ## [0.0.2] - 2024-06-15
21
+
22
+ ### Changed
23
+
24
+ - **Package Name**:
25
+ - Renamed from "TSSuper" to "@thainanluiz/tssuper".
26
+
27
+ ### Links
28
+
29
+ - [Version 0.0.2 on npm](https://www.npmjs.com/package/@thainanluiz/tssuper/v/0.0.2)
30
+
31
+ ---
32
+
33
+ ## [0.0.1] - 2024-06-15
10
34
 
11
35
  ### Added
12
36
 
13
- - randomInt function.
37
+ - **randomInt function**:
38
+ - Generates a random integer within a specified range.
39
+
40
+ ### Links
41
+
42
+ - [Version 0.0.1 on npm](https://www.npmjs.com/package/@thainanluiz/tssuper/v/0.0.1)
43
+
44
+ ---
45
+
46
+ ## Migration Notice
47
+
48
+ 🎉 Welcome! We are excited to introduce you to the new and improved version of TSSUPER (formerly JSSUPER). This migration brings enhanced features, improved performance, and a more user-friendly experience. Thank you for your continued support and feedback!
14
49
 
15
- ### Migration
50
+ ---
16
51
 
17
- > **🎉 Welcome! We are excited to introduce you to the new and improved version of JSSUPER (now [TSSuper]). This project has been migrated to offer better features, enhanced performance, and a more user-friendly experience. Thank you for joining us on this journey!**
52
+ ## Notes
18
53
 
19
- [@thainanluiz]: https://github.com/thainanluiz
20
- [0.0.1]: https://www.npmjs.com/package/@thainanluiz/tssuper/v/0.0.1
21
- [TSSuper]: https://github.com/thainanluiz/TSSuper
54
+ - **Author**: [@thainanluiz](https://github.com/thainanluiz)
55
+ - **Repository**: [TSSuper on GitHub](https://github.com/thainanluiz/TSSuper)
package/FUNCTIONS.md CHANGED
@@ -1,12 +1,39 @@
1
1
  # Current Functions Available
2
2
 
3
- ## 0.0.1
3
+ ## 0.0.6
4
+
5
+ - [formatNumber](https://github.com/thainanluiz/TSSuper/blob/main/examples/formatNumber.ts) ({ number: number, decimalPlaces: number })
6
+
7
+ Formats a number to a specified number of decimal places.
8
+
9
+ ### Parameters
4
10
 
5
- - [randomInt](https://github.com/thainanluiz/TSSuper/blob/main/examples/randomInt.ts)( {min: number, max: number } ) <br>
6
- Will return a value between the maximum and minimum number.
11
+ - `number`: The number to be formatted.
12
+ - `decimalPlaces`: Number of decimal places to round to.
13
+
14
+ ### Returns
15
+
16
+ Returns the formatted number.
7
17
 
8
18
  <br>
9
19
 
10
- _Default min and max values ​​({min: 0, max: 10})_
20
+ ## 0.0.1
21
+
22
+ - [randomInt](https://github.com/thainanluiz/TSSuper/blob/main/examples/randomInt.ts) ({ min: number, max: number })
23
+
24
+ Generates a random integer between the specified minimum and maximum values.
25
+
26
+ ### Parameters
27
+
28
+ - `min`: Minimum value (inclusive).
29
+ - `max`: Maximum value (inclusive).
30
+
31
+ ### Returns
32
+
33
+ Returns a random integer between `min` and `max`.
34
+
35
+ ### Default Range
36
+
37
+ Default values for `min` and `max` are `{ min: 0, max: 10 }`.
11
38
 
12
39
  <br>
package/README.md CHANGED
@@ -11,25 +11,26 @@ How to install
11
11
  npm i @thainanluiz/tssuper
12
12
  ```
13
13
 
14
- Package available [here] | current stable version [?.?.?] | current version [0.0.2]
14
+ Package available [here] | current stable version [1.0.0] | current version [0.0.7]
15
15
 
16
16
  <br>
17
17
 
18
- How to import
18
+ How to use
19
19
 
20
20
  ```ts
21
- const tssuper = require("@thainanluiz/tssuper");
21
+ const { math } = require("@thainanluiz/tssuper");
22
22
  ```
23
23
 
24
24
  <br>
25
25
 
26
- See [functions.md] to get available functions <br>
26
+ See [functions] to get available functions <br>
27
27
  See [examples] folder <br>
28
28
  The entire [changelog here] <br>
29
29
 
30
- [functions.md]: https://github.com/thainanluiz/TSSuper/blob/main/FUNCTIONS.md
31
30
  [here]: https://www.npmjs.com/package/@thainanluiz/tssuper
31
+ [1.0.0]: https://www.npmjs.com/package/@thainanluiz/tssuper/v/1.0.0
32
+ [0.0.7]: https://www.npmjs.com/package/@thainanluiz/tssuper/v/0.0.7
33
+ [functions]: https://github.com/thainanluiz/TSSuper/blob/main/FUNCTIONS.md
32
34
  [examples]: https://github.com/thainanluiz/TSSuper/blob/main/examples/
33
35
  [changelog here]: https://github.com/thainanluiz/TSSuper/blob/main/CHANGELOG.md
34
- [0.0.2]: https://www.npmjs.com/package/@thainanluiz/tssuper/v/0.0.2
35
36
  [TSSuper]: https://github.com/thainanluiz/TSSuper
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
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@thainanluiz/tssuper",
3
- "version": "0.0.5",
3
+ "version": "0.0.7",
4
4
  "description": "Simple add-on for TypeScript",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",
@@ -17,6 +17,14 @@
17
17
  "addon",
18
18
  "library"
19
19
  ],
20
+ "repository": {
21
+ "type": "git",
22
+ "url": "git+https://github.com/thainanluiz/TSSuper.git"
23
+ },
24
+ "bugs": {
25
+ "url": "https://github.com/thainanluiz/TSSuper/issues"
26
+ },
27
+ "homepage": "https://github.com/thainanluiz/TSSuper#readme",
20
28
  "author": "Thainan Luiz",
21
29
  "license": "GPL-3.0-only",
22
30
  "devDependencies": {