@thainanluiz/tssuper 0.0.9 → 0.0.11
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 +22 -9
- package/FUNCTIONS.md +38 -2
- package/README.md +3 -2
- package/dist/index.d.mts +33 -6
- package/dist/index.d.ts +33 -6
- package/dist/index.js +1 -1
- package/dist/index.mjs +1 -1
- package/package.json +4 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,7 +2,28 @@
|
|
|
2
2
|
|
|
3
3
|
This document summarizes the updates and changes made to the TSSUPER project.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
## [0.0.11] - 2024-07-10
|
|
6
|
+
|
|
7
|
+
### Added
|
|
8
|
+
|
|
9
|
+
- **fixedRepeater function**:
|
|
10
|
+
|
|
11
|
+
- Repeats a function for a fixed amount of time.
|
|
12
|
+
|
|
13
|
+
### Links
|
|
14
|
+
|
|
15
|
+
- [Version 0.0.11 on npm](https://www.npmjs.com/package/@thainanluiz/tssuper/v/0.0.11)
|
|
16
|
+
|
|
17
|
+
## [0.0.10] - 2024-07-10
|
|
18
|
+
|
|
19
|
+
### Added
|
|
20
|
+
|
|
21
|
+
- **fixedDelay function**:
|
|
22
|
+
- Delays the execution of a function for a fixed amount of time.
|
|
23
|
+
|
|
24
|
+
### Links
|
|
25
|
+
|
|
26
|
+
- [Version 0.0.10 on npm](https://www.npmjs.com/package/@thainanluiz/tssuper/v/0.0.10)
|
|
6
27
|
|
|
7
28
|
## [0.0.6] - 2024-06-15
|
|
8
29
|
|
|
@@ -15,8 +36,6 @@ This document summarizes the updates and changes made to the TSSUPER project.
|
|
|
15
36
|
|
|
16
37
|
- [Version 0.0.6 on npm](https://www.npmjs.com/package/@thainanluiz/tssuper/v/0.0.6)
|
|
17
38
|
|
|
18
|
-
---
|
|
19
|
-
|
|
20
39
|
## [0.0.2] - 2024-06-15
|
|
21
40
|
|
|
22
41
|
### Changed
|
|
@@ -28,8 +47,6 @@ This document summarizes the updates and changes made to the TSSUPER project.
|
|
|
28
47
|
|
|
29
48
|
- [Version 0.0.2 on npm](https://www.npmjs.com/package/@thainanluiz/tssuper/v/0.0.2)
|
|
30
49
|
|
|
31
|
-
---
|
|
32
|
-
|
|
33
50
|
## [0.0.1] - 2024-06-15
|
|
34
51
|
|
|
35
52
|
### Added
|
|
@@ -41,14 +58,10 @@ This document summarizes the updates and changes made to the TSSUPER project.
|
|
|
41
58
|
|
|
42
59
|
- [Version 0.0.1 on npm](https://www.npmjs.com/package/@thainanluiz/tssuper/v/0.0.1)
|
|
43
60
|
|
|
44
|
-
---
|
|
45
|
-
|
|
46
61
|
## Migration Notice
|
|
47
62
|
|
|
48
63
|
🎉 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!
|
|
49
64
|
|
|
50
|
-
---
|
|
51
|
-
|
|
52
65
|
## Notes
|
|
53
66
|
|
|
54
67
|
- **Author**: [@thainanluiz](https://github.com/thainanluiz)
|
package/FUNCTIONS.md
CHANGED
|
@@ -1,8 +1,44 @@
|
|
|
1
1
|
# Current Functions Available
|
|
2
2
|
|
|
3
|
+
## 0.0.11
|
|
4
|
+
|
|
5
|
+
- [fixedRepeater](https://github.com/thainanluiz/TSSuper/blob/main/examples/delay/fixedRepeater.ts) ({ callback: Function, ms: number, times: number })
|
|
6
|
+
|
|
7
|
+
Repeats a function for a fixed amount of time.
|
|
8
|
+
|
|
9
|
+
### Parameters
|
|
10
|
+
|
|
11
|
+
- `callback`: Function to be repeated.
|
|
12
|
+
- `ms`: Time in milliseconds to repeat the function.
|
|
13
|
+
- `times`: Number of times to repeat the function.
|
|
14
|
+
|
|
15
|
+
### Returns
|
|
16
|
+
|
|
17
|
+
Returns a promise that resolves when the function is done repeating.
|
|
18
|
+
|
|
19
|
+
<br>
|
|
20
|
+
|
|
21
|
+
## 0.0.10
|
|
22
|
+
|
|
23
|
+
- [fixedDelay](https://github.com/thainanluiz/TSSuper/blob/main/examples/delay/fixedDelay.ts) ({ ms: number, breakAt: number, returnElapsed: boolean })
|
|
24
|
+
|
|
25
|
+
Delays the execution of a function for a fixed amount of time.
|
|
26
|
+
|
|
27
|
+
### Parameters
|
|
28
|
+
|
|
29
|
+
- `ms`: Time in milliseconds to delay the execution.
|
|
30
|
+
- `breakAt`: Time in milliseconds to break the delay.
|
|
31
|
+
- `returnElapsed`: If `true`, returns the elapsed time.
|
|
32
|
+
|
|
33
|
+
### Returns
|
|
34
|
+
|
|
35
|
+
Returns the elapsed time if `returnElapsed` is `true`.
|
|
36
|
+
|
|
37
|
+
<br>
|
|
38
|
+
|
|
3
39
|
## 0.0.6
|
|
4
40
|
|
|
5
|
-
- [formatNumber](https://github.com/thainanluiz/TSSuper/blob/main/examples/formatNumber.ts) ({ number: number, decimalPlaces: number })
|
|
41
|
+
- [formatNumber](https://github.com/thainanluiz/TSSuper/blob/main/examples/math/formatNumber.ts) ({ number: number, decimalPlaces: number })
|
|
6
42
|
|
|
7
43
|
Formats a number to a specified number of decimal places.
|
|
8
44
|
|
|
@@ -19,7 +55,7 @@
|
|
|
19
55
|
|
|
20
56
|
## 0.0.1
|
|
21
57
|
|
|
22
|
-
- [randomInt](https://github.com/thainanluiz/TSSuper/blob/main/examples/randomInt.ts) ({ min: number, max: number })
|
|
58
|
+
- [randomInt](https://github.com/thainanluiz/TSSuper/blob/main/examples/math/randomInt.ts) ({ min: number, max: number })
|
|
23
59
|
|
|
24
60
|
Generates a random integer between the specified minimum and maximum values.
|
|
25
61
|
|
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 [
|
|
14
|
+
Package available [here] | current stable version [0.0.11] | current version [0.0.11]
|
|
15
15
|
|
|
16
16
|
<br>
|
|
17
17
|
|
|
@@ -19,6 +19,7 @@ How to use
|
|
|
19
19
|
|
|
20
20
|
```ts
|
|
21
21
|
const { math } = require("@thainanluiz/tssuper");
|
|
22
|
+
const { delay } = require("@thainanluiz/tssuper");
|
|
22
23
|
```
|
|
23
24
|
|
|
24
25
|
<br>
|
|
@@ -29,7 +30,7 @@ The entire [changelog here] <br>
|
|
|
29
30
|
|
|
30
31
|
[here]: https://www.npmjs.com/package/@thainanluiz/tssuper
|
|
31
32
|
[1.0.0]: https://www.npmjs.com/package/@thainanluiz/tssuper/v/1.0.0
|
|
32
|
-
[0.0.
|
|
33
|
+
[0.0.11]: https://www.npmjs.com/package/@thainanluiz/tssuper/v/0.0.11
|
|
33
34
|
[functions]: https://github.com/thainanluiz/TSSuper/blob/main/FUNCTIONS.md
|
|
34
35
|
[examples]: https://github.com/thainanluiz/TSSuper/blob/main/examples/
|
|
35
36
|
[changelog here]: https://github.com/thainanluiz/TSSuper/blob/main/CHANGELOG.md
|
package/dist/index.d.mts
CHANGED
|
@@ -31,12 +31,39 @@ type FormatNumberProps = {
|
|
|
31
31
|
*/
|
|
32
32
|
declare function formatNumber({ number, decimalPlaces, }: FormatNumberProps): number;
|
|
33
33
|
|
|
34
|
-
type
|
|
35
|
-
type
|
|
36
|
-
declare const
|
|
37
|
-
declare const
|
|
34
|
+
type index$1_FormatNumberProps = FormatNumberProps;
|
|
35
|
+
type index$1_RandomIntProps = RandomIntProps;
|
|
36
|
+
declare const index$1_formatNumber: typeof formatNumber;
|
|
37
|
+
declare const index$1_randomInt: typeof randomInt;
|
|
38
|
+
declare namespace index$1 {
|
|
39
|
+
export { type index$1_FormatNumberProps as FormatNumberProps, type index$1_RandomIntProps as RandomIntProps, index$1_formatNumber as formatNumber, index$1_randomInt as randomInt };
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
type FixedDelayProps = {
|
|
43
|
+
ms: number;
|
|
44
|
+
breakAt?: number;
|
|
45
|
+
returnElapsed?: boolean;
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Create a fixed delay function that returns a promise that resolves after a given number of milliseconds.
|
|
50
|
+
* @param {FixedDelayProps} { ms, breakAt, returnElapsed }
|
|
51
|
+
*
|
|
52
|
+
* @returns {object} An object containing the promise and a cancel function
|
|
53
|
+
*
|
|
54
|
+
* @throws {Error} ms must be a positive number
|
|
55
|
+
* @throws {Error} breakAt must be a positive number if defined
|
|
56
|
+
* @throws {Error} returnElapsed must be a boolean if defined
|
|
57
|
+
*/
|
|
58
|
+
declare function fixedDelay({ ms, breakAt, returnElapsed }: FixedDelayProps): {
|
|
59
|
+
promise: Promise<number | void>;
|
|
60
|
+
cancel: () => void;
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
type index_FixedDelayProps = FixedDelayProps;
|
|
64
|
+
declare const index_fixedDelay: typeof fixedDelay;
|
|
38
65
|
declare namespace index {
|
|
39
|
-
export { type
|
|
66
|
+
export { type index_FixedDelayProps as FixedDelayProps, index_fixedDelay as fixedDelay };
|
|
40
67
|
}
|
|
41
68
|
|
|
42
|
-
export { index as math };
|
|
69
|
+
export { index as delay, index$1 as math };
|
package/dist/index.d.ts
CHANGED
|
@@ -31,12 +31,39 @@ type FormatNumberProps = {
|
|
|
31
31
|
*/
|
|
32
32
|
declare function formatNumber({ number, decimalPlaces, }: FormatNumberProps): number;
|
|
33
33
|
|
|
34
|
-
type
|
|
35
|
-
type
|
|
36
|
-
declare const
|
|
37
|
-
declare const
|
|
34
|
+
type index$1_FormatNumberProps = FormatNumberProps;
|
|
35
|
+
type index$1_RandomIntProps = RandomIntProps;
|
|
36
|
+
declare const index$1_formatNumber: typeof formatNumber;
|
|
37
|
+
declare const index$1_randomInt: typeof randomInt;
|
|
38
|
+
declare namespace index$1 {
|
|
39
|
+
export { type index$1_FormatNumberProps as FormatNumberProps, type index$1_RandomIntProps as RandomIntProps, index$1_formatNumber as formatNumber, index$1_randomInt as randomInt };
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
type FixedDelayProps = {
|
|
43
|
+
ms: number;
|
|
44
|
+
breakAt?: number;
|
|
45
|
+
returnElapsed?: boolean;
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Create a fixed delay function that returns a promise that resolves after a given number of milliseconds.
|
|
50
|
+
* @param {FixedDelayProps} { ms, breakAt, returnElapsed }
|
|
51
|
+
*
|
|
52
|
+
* @returns {object} An object containing the promise and a cancel function
|
|
53
|
+
*
|
|
54
|
+
* @throws {Error} ms must be a positive number
|
|
55
|
+
* @throws {Error} breakAt must be a positive number if defined
|
|
56
|
+
* @throws {Error} returnElapsed must be a boolean if defined
|
|
57
|
+
*/
|
|
58
|
+
declare function fixedDelay({ ms, breakAt, returnElapsed }: FixedDelayProps): {
|
|
59
|
+
promise: Promise<number | void>;
|
|
60
|
+
cancel: () => void;
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
type index_FixedDelayProps = FixedDelayProps;
|
|
64
|
+
declare const index_fixedDelay: typeof fixedDelay;
|
|
38
65
|
declare namespace index {
|
|
39
|
-
export { type
|
|
66
|
+
export { type index_FixedDelayProps as FixedDelayProps, index_fixedDelay as fixedDelay };
|
|
40
67
|
}
|
|
41
68
|
|
|
42
|
-
export { index as math };
|
|
69
|
+
export { index as delay, index$1 as math };
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var p=Object.defineProperty;var w=Object.getOwnPropertyDescriptor;var l=Object.getOwnPropertyNames;var y=Object.prototype.hasOwnProperty;var a=(r,e)=>{for(var o in e)p(r,o,{get:e[o],enumerable:!0})},P=(r,e,o,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let t of l(e))!y.call(r,t)&&t!==o&&p(r,t,{get:()=>e[t],enumerable:!(n=w(e,t))||n.enumerable});return r};var h=r=>P(p({},"__esModule",{value:!0}),r);var N={};a(N,{delay:()=>u,math:()=>f});module.exports=h(N);var f={};a(f,{formatNumber:()=>b,randomInt:()=>d});function d({min:r,max:e}){if(typeof r!="number"||typeof e!="number")throw new Error("min and max must be numbers");if(!Number.isInteger(r)||!Number.isInteger(e))throw new Error("min and max must be integers");if(r>e)throw new Error("min must be less than or equal to max");return Math.floor(Math.random()*(e-r+1))+r}function b({number:r,decimalPlaces:e}){if(typeof r!="number")throw new Error("number must be a number");if(!Number.isInteger(e))throw new Error("decimalPlaces must be an integer");return Number(r.toFixed(e))}var u={};a(u,{fixedDelay:()=>x});function x({ms:r,breakAt:e,returnElapsed:o}){if(typeof r!="number"||r<=0)throw new Error("ms must be a positive number");if(e!==void 0&&(typeof e!="number"||e<=0))throw new Error("breakAt must be a positive number if defined");if(o!==void 0&&typeof o!="boolean")throw new Error("returnElapsed must be a boolean if defined");let n,t=Date.now(),s;return{promise:new Promise(i=>{s=i,n=setTimeout(()=>{o?i(Date.now()-t):i()},r),e&&setTimeout(()=>{clearTimeout(n),i(o?Date.now()-t:void 0)},e)}),cancel:()=>{clearTimeout(n),s(o?Date.now()-t:void 0)}}}0&&(module.exports={delay,math});
|
package/dist/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var
|
|
1
|
+
var w=Object.defineProperty;var s=(r,e)=>{for(var m in e)w(r,m,{get:e[m],enumerable:!0})};var u={};s(u,{formatNumber:()=>b,randomInt:()=>d});function d({min:r,max:e}){if(typeof r!="number"||typeof e!="number")throw new Error("min and max must be numbers");if(!Number.isInteger(r)||!Number.isInteger(e))throw new Error("min and max must be integers");if(r>e)throw new Error("min must be less than or equal to max");return Math.floor(Math.random()*(e-r+1))+r}function b({number:r,decimalPlaces:e}){if(typeof r!="number")throw new Error("number must be a number");if(!Number.isInteger(e))throw new Error("decimalPlaces must be an integer");return Number(r.toFixed(e))}var p={};s(p,{fixedDelay:()=>x});function x({ms:r,breakAt:e,returnElapsed:m}){if(typeof r!="number"||r<=0)throw new Error("ms must be a positive number");if(e!==void 0&&(typeof e!="number"||e<=0))throw new Error("breakAt must be a positive number if defined");if(m!==void 0&&typeof m!="boolean")throw new Error("returnElapsed must be a boolean if defined");let i,f=Date.now(),a;return{promise:new Promise(n=>{a=n,i=setTimeout(()=>{m?n(Date.now()-f):n()},r),e&&setTimeout(()=>{clearTimeout(i),n(m?Date.now()-f:void 0)},e)}),cancel:()=>{clearTimeout(i),a(m?Date.now()-f:void 0)}}}export{p as delay,u as math};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@thainanluiz/tssuper",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.11",
|
|
4
4
|
"description": "Simple add-on for TypeScript",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"module": "./dist/index.mjs",
|
|
@@ -33,5 +33,8 @@
|
|
|
33
33
|
"ts-jest": "^29.1.4",
|
|
34
34
|
"tsup": "^8.1.0",
|
|
35
35
|
"typescript": "^5.4.5"
|
|
36
|
+
},
|
|
37
|
+
"dependencies": {
|
|
38
|
+
"ulid": "^2.3.0"
|
|
36
39
|
}
|
|
37
40
|
}
|