@thainanluiz/tssuper 0.0.6 → 0.0.8

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 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.6]
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.6]: https://www.npmjs.com/package/@thainanluiz/tssuper/v/0.0.6
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
@@ -1,49 +1 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
-
20
- // src/index.ts
21
- var src_exports = {};
22
- __export(src_exports, {
23
- math: () => math_exports
24
- });
25
- module.exports = __toCommonJS(src_exports);
26
-
27
- // src/math/index.ts
28
- var math_exports = {};
29
- __export(math_exports, {
30
- randomInt: () => randomInt
31
- });
32
-
33
- // src/math/functions/randomInt.ts
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
- }
44
- return Math.floor(Math.random() * (max - min + 1)) + min;
45
- }
46
- // Annotate the CommonJS export names for ESM import in node:
47
- 0 && (module.exports = {
48
- math
49
- });
1
+ "use strict";var u=Object.defineProperty;var s=Object.getOwnPropertyDescriptor;var i=Object.getOwnPropertyNames;var d=Object.prototype.hasOwnProperty;var a=(o,r)=>{for(var m in r)u(o,m,{get:r[m],enumerable:!0})},w=(o,r,m,p)=>{if(r&&typeof r=="object"||typeof r=="function")for(let e of i(r))!d.call(o,e)&&e!==m&&u(o,e,{get:()=>r[e],enumerable:!(p=s(r,e))||p.enumerable});return o};var x=o=>w(u({},"__esModule",{value:!0}),o);var N={};a(N,{math:()=>n});module.exports=x(N);var n={};a(n,{formatNumber:()=>b,randomInt:()=>f});function f({min:o,max:r}){if(typeof o!="number"||typeof r!="number")throw new Error("min and max must be numbers");if(!Number.isInteger(o)||!Number.isInteger(r))throw new Error("min and max must be integers");if(o>r)throw new Error("min must be less than or equal to max");return Math.floor(Math.random()*(r-o+1))+o}function b({number:o,decimalPlaces:r}){if(typeof o!="number")throw new Error("number must be a number");if(!Number.isInteger(r))throw new Error("decimalPlaces must be an integer");return Number(o.toFixed(r))}0&&(module.exports={math});
package/dist/index.mjs CHANGED
@@ -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
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
- }
24
- return Math.floor(Math.random() * (max - min + 1)) + min;
25
- }
26
- export {
27
- math_exports as math
28
- };
1
+ var a=Object.defineProperty;var f=(r,o)=>{for(var n in o)a(r,n,{get:o[n],enumerable:!0})};var m={};f(m,{formatNumber:()=>p,randomInt:()=>u});function u({min:r,max:o}){if(typeof r!="number"||typeof o!="number")throw new Error("min and max must be numbers");if(!Number.isInteger(r)||!Number.isInteger(o))throw new Error("min and max must be integers");if(r>o)throw new Error("min must be less than or equal to max");return Math.floor(Math.random()*(o-r+1))+r}function p({number:r,decimalPlaces:o}){if(typeof r!="number")throw new Error("number must be a number");if(!Number.isInteger(o))throw new Error("decimalPlaces must be an integer");return Number(r.toFixed(o))}export{m as math};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@thainanluiz/tssuper",
3
- "version": "0.0.6",
3
+ "version": "0.0.8",
4
4
  "description": "Simple add-on for TypeScript",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",