tiny-essentials 1.3.0 → 1.3.2

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.
Files changed (127) hide show
  1. package/dist/TinyBasicsEs.js +3 -3
  2. package/dist/TinyBasicsEs.min.js +1 -1
  3. package/dist/TinyEssentials.js +26 -18
  4. package/dist/TinyEssentials.min.js +1 -1
  5. package/dist/TinyLevelUp.js +23 -15
  6. package/dist/legacy/firebase/cookieSession.cjs +1 -1
  7. package/dist/legacy/firebase/cookieSession.d.mts +2 -2
  8. package/dist/legacy/firebase/cookieSession.mjs +1 -1
  9. package/dist/legacy/firebase/databaseLogger.cjs +5 -5
  10. package/dist/legacy/firebase/databaseLogger.d.mts +2 -2
  11. package/dist/legacy/firebase/databaseLogger.mjs +5 -5
  12. package/dist/legacy/firebase/discord/api/addGuildMember.cjs +2 -2
  13. package/dist/legacy/firebase/discord/api/addGuildMember.d.mts +3 -3
  14. package/dist/legacy/firebase/discord/api/addGuildMember.mjs +2 -2
  15. package/dist/legacy/firebase/discord/api/getGuildWidget.cjs +2 -2
  16. package/dist/legacy/firebase/discord/api/getGuildWidget.d.mts +3 -3
  17. package/dist/legacy/firebase/discord/api/getGuildWidget.mjs +2 -2
  18. package/dist/legacy/firebase/discord/api/getToken.cjs +2 -2
  19. package/dist/legacy/firebase/discord/api/getToken.d.mts +3 -3
  20. package/dist/legacy/firebase/discord/api/getToken.mjs +2 -2
  21. package/dist/legacy/firebase/discord/api/getUser.cjs +2 -2
  22. package/dist/legacy/firebase/discord/api/getUser.d.mts +3 -3
  23. package/dist/legacy/firebase/discord/api/getUser.mjs +2 -2
  24. package/dist/legacy/firebase/discord/api/getUserConnections.cjs +2 -2
  25. package/dist/legacy/firebase/discord/api/getUserConnections.d.mts +3 -3
  26. package/dist/legacy/firebase/discord/api/getUserConnections.mjs +2 -2
  27. package/dist/legacy/firebase/discord/api/getUserGuilds.cjs +2 -2
  28. package/dist/legacy/firebase/discord/api/getUserGuilds.d.mts +3 -3
  29. package/dist/legacy/firebase/discord/api/getUserGuilds.mjs +2 -2
  30. package/dist/legacy/firebase/discord/api/refreshToken.cjs +2 -2
  31. package/dist/legacy/firebase/discord/api/refreshToken.d.mts +3 -3
  32. package/dist/legacy/firebase/discord/api/refreshToken.mjs +2 -2
  33. package/dist/legacy/firebase/discord/api/revokeToken.cjs +2 -2
  34. package/dist/legacy/firebase/discord/api/revokeToken.d.mts +3 -3
  35. package/dist/legacy/firebase/discord/api/revokeToken.mjs +2 -2
  36. package/dist/legacy/firebase/discord/get/authURLGenerator.cjs +3 -3
  37. package/dist/legacy/firebase/discord/get/authURLGenerator.d.mts +4 -4
  38. package/dist/legacy/firebase/discord/get/authURLGenerator.mjs +3 -3
  39. package/dist/legacy/firebase/discord/get/cookie-session.cjs +1 -1
  40. package/dist/legacy/firebase/discord/get/cookie-session.d.mts +2 -2
  41. package/dist/legacy/firebase/discord/get/cookie-session.mjs +1 -1
  42. package/dist/legacy/firebase/discord/get/errorValidator.cjs +1 -1
  43. package/dist/legacy/firebase/discord/get/errorValidator.d.mts +2 -2
  44. package/dist/legacy/firebase/discord/get/errorValidator.mjs +1 -1
  45. package/dist/legacy/firebase/discord/http/login.cjs +3 -3
  46. package/dist/legacy/firebase/discord/http/login.d.mts +4 -4
  47. package/dist/legacy/firebase/discord/http/login.mjs +3 -3
  48. package/dist/legacy/firebase/discord/http/logout.cjs +4 -4
  49. package/dist/legacy/firebase/discord/http/logout.d.mts +5 -5
  50. package/dist/legacy/firebase/discord/http/logout.mjs +4 -4
  51. package/dist/legacy/firebase/discord/http/redirect.cjs +4 -4
  52. package/dist/legacy/firebase/discord/http/redirect.d.mts +5 -5
  53. package/dist/legacy/firebase/discord/http/redirect.mjs +4 -4
  54. package/dist/legacy/firebase/discord/http/refreshToken.cjs +4 -4
  55. package/dist/legacy/firebase/discord/http/refreshToken.d.mts +5 -5
  56. package/dist/legacy/firebase/discord/http/refreshToken.mjs +4 -4
  57. package/dist/legacy/firebase/discord/template/cookie-session.cjs +2 -2
  58. package/dist/legacy/firebase/discord/template/cookie-session.d.mts +5 -5
  59. package/dist/legacy/firebase/discord/template/cookie-session.mjs +2 -2
  60. package/dist/legacy/firebase/escape.cjs +1 -1
  61. package/dist/legacy/firebase/escape.d.mts +2 -2
  62. package/dist/legacy/firebase/escape.mjs +1 -1
  63. package/dist/legacy/firebase/index.cjs +6 -6
  64. package/dist/legacy/firebase/index.d.mts +7 -7
  65. package/dist/legacy/firebase/index.mjs +6 -6
  66. package/dist/legacy/firebase/logger.cjs +5 -5
  67. package/dist/legacy/firebase/logger.d.mts +4 -4
  68. package/dist/legacy/firebase/logger.mjs +5 -5
  69. package/dist/legacy/firebase/mySQL.cjs +2 -2
  70. package/dist/legacy/firebase/mySQL.d.mts +3 -3
  71. package/dist/legacy/firebase/mySQL.mjs +2 -2
  72. package/dist/legacy/firebase/mysqlConnector/create.cjs +4 -4
  73. package/dist/legacy/firebase/mysqlConnector/create.d.mts +5 -5
  74. package/dist/legacy/firebase/mysqlConnector/create.mjs +4 -4
  75. package/dist/legacy/firebase/mysqlConnector/nextPrev.cjs +2 -2
  76. package/dist/legacy/firebase/mysqlConnector/nextPrev.d.mts +4 -4
  77. package/dist/legacy/firebase/mysqlConnector/nextPrev.mjs +2 -2
  78. package/dist/legacy/firebase/mysqlConnector/pagination.cjs +4 -4
  79. package/dist/legacy/firebase/mysqlConnector/pagination.d.mts +6 -6
  80. package/dist/legacy/firebase/mysqlConnector/pagination.mjs +4 -4
  81. package/dist/legacy/firebase/transactionDBAsync.cjs +1 -1
  82. package/dist/legacy/firebase/transactionDBAsync.d.mts +2 -2
  83. package/dist/legacy/firebase/transactionDBAsync.mjs +1 -1
  84. package/dist/legacy/get/pagination.cjs +1 -1
  85. package/dist/legacy/get/pagination.d.mts +2 -2
  86. package/dist/legacy/get/pagination.mjs +1 -1
  87. package/dist/legacy/get/versionCheck.cjs +1 -1
  88. package/dist/legacy/get/versionCheck.d.mts +2 -2
  89. package/dist/legacy/get/versionCheck.mjs +1 -1
  90. package/dist/legacy/http/check_domain.cjs +2 -2
  91. package/dist/legacy/http/check_domain.d.mts +2 -2
  92. package/dist/legacy/http/check_domain.mjs +2 -2
  93. package/dist/legacy/http/csrfTokenAnalyze.cjs +2 -2
  94. package/dist/legacy/http/csrfTokenAnalyze.d.mts +3 -3
  95. package/dist/legacy/http/csrfTokenAnalyze.mjs +2 -2
  96. package/dist/legacy/http/domainValidator.cjs +3 -3
  97. package/dist/legacy/http/domainValidator.d.mts +4 -4
  98. package/dist/legacy/http/domainValidator.mjs +3 -3
  99. package/dist/legacy/http/userIP.cjs +1 -1
  100. package/dist/legacy/http/userIP.d.mts +2 -4
  101. package/dist/legacy/http/userIP.mjs +1 -1
  102. package/dist/legacy/index.d.mts +4 -4
  103. package/dist/legacy/libs/custom_module_loader.cjs +2 -2
  104. package/dist/legacy/libs/custom_module_loader.d.mts +2 -2
  105. package/dist/legacy/libs/custom_module_loader.mjs +2 -2
  106. package/dist/legacy/libs/userLevel.cjs +23 -15
  107. package/dist/legacy/libs/userLevel.d.mts +41 -19
  108. package/dist/legacy/libs/userLevel.mjs +21 -15
  109. package/dist/legacy/socket.io/antiFlood/install.cjs +3 -3
  110. package/dist/legacy/socket.io/antiFlood/install.d.mts +4 -6
  111. package/dist/legacy/socket.io/antiFlood/install.mjs +3 -3
  112. package/dist/legacy/socket.io/antiFlood/verify.cjs +4 -4
  113. package/dist/legacy/socket.io/antiFlood/verify.d.mts +5 -7
  114. package/dist/legacy/socket.io/antiFlood/verify.mjs +4 -4
  115. package/dist/legacy/socket.io/cookie-session.cjs +2 -2
  116. package/dist/legacy/socket.io/cookie-session.d.mts +3 -3
  117. package/dist/legacy/socket.io/cookie-session.mjs +2 -2
  118. package/dist/legacy/socket.io/discord.cjs +3 -3
  119. package/dist/legacy/socket.io/discord.d.mts +4 -4
  120. package/dist/legacy/socket.io/discord.mjs +3 -3
  121. package/dist/v1/basics/clock.cjs +1 -1
  122. package/dist/v1/basics/clock.d.mts +1 -1
  123. package/dist/v1/basics/clock.mjs +1 -1
  124. package/dist/v1/basics/simpleMath.cjs +2 -2
  125. package/dist/v1/basics/simpleMath.d.mts +2 -2
  126. package/dist/v1/basics/simpleMath.mjs +2 -2
  127. package/package.json +1 -1
@@ -11,16 +11,26 @@ declare class TinyLevelUp {
11
11
  constructor(giveExp: number, expLevel: number);
12
12
  giveExp: number;
13
13
  expLevel: number;
14
+ /**
15
+ * @typedef {{ exp: number, level: number, totalExp: number }} UserResult
16
+ */
17
+ /**
18
+ * @typedef {{ exp: number, level: number, totalExp: any }} UserEditor
19
+ */
14
20
  /**
15
21
  * Validates and adjusts the user's level based on their current experience.
16
- * @param {{ exp: number, level: number, totalExp: any }} user - The user object containing experience and level properties.
17
- * @returns {Object} The updated user object.
22
+ * @param {UserEditor} user - The user object containing experience and level properties.
23
+ * @returns {UserResult} The updated user object.
18
24
  */
19
25
  expValidator(user: {
20
26
  exp: number;
21
27
  level: number;
22
28
  totalExp: any;
23
- }): Object;
29
+ }): {
30
+ exp: number;
31
+ level: number;
32
+ totalExp: number;
33
+ };
24
34
  /**
25
35
  * Calculates the total experience based on the user's level.
26
36
  * @param {{ exp: number, level: number }} user - The user object containing experience and level properties.
@@ -32,7 +42,7 @@ declare class TinyLevelUp {
32
42
  }): number;
33
43
  /**
34
44
  * Generates random experience points based on the configured multiplier.
35
- * @param {number} multi - A multiplier for the generated experience.
45
+ * @param {number} [multi] - A multiplier for the generated experience.
36
46
  * @returns {number} The generated experience points.
37
47
  */
38
48
  expGenerator(multi?: number): number;
@@ -54,39 +64,51 @@ declare class TinyLevelUp {
54
64
  }): number;
55
65
  /**
56
66
  * Sets the experience value for the user, adjusting their level if necessary.
57
- * @param {{ exp: number, level: number, totalExp: any }} user - The user object.
67
+ * @param {UserEditor} user - The user object.
58
68
  * @param {number} value - The new experience value to set.
59
- * @returns {Object} The updated user object.
69
+ * @returns {UserResult} The updated user object.
60
70
  */
61
71
  set(user: {
62
72
  exp: number;
63
73
  level: number;
64
74
  totalExp: any;
65
- }, value: number): Object;
75
+ }, value: number): {
76
+ exp: number;
77
+ level: number;
78
+ totalExp: number;
79
+ };
66
80
  /**
67
81
  * Adds experience to the user, adjusting their level if necessary.
68
- * @param {{ exp: number, level: number, totalExp: any }} user - The user object.
69
- * @param {number} extraExp - Additional experience to be added.
70
- * @param {'add' | 'extra'} type - Type of addition ('add' or 'extra').
71
- * @param {number} multi - Multiplier for experience generation.
72
- * @returns {Object} The updated user object.
82
+ * @param {UserEditor} user - The user object.
83
+ * @param {number} [extraExp] - Additional experience to be added.
84
+ * @param {'add' | 'extra'} [type] - Type of addition ('add' or 'extra').
85
+ * @param {number} [multi] - Multiplier for experience generation.
86
+ * @returns {UserResult} The updated user object.
73
87
  */
74
88
  give(user: {
75
89
  exp: number;
76
90
  level: number;
77
91
  totalExp: any;
78
- }, extraExp?: number, type?: "add" | "extra", multi?: number): Object;
92
+ }, extraExp?: number, type?: "add" | "extra", multi?: number): {
93
+ exp: number;
94
+ level: number;
95
+ totalExp: number;
96
+ };
79
97
  /**
80
98
  * Removes experience from the user, adjusting their level if necessary.
81
- * @param {{ exp: number, level: number, totalExp: any }} user - The user object.
82
- * @param {number} extraExp - Experience to remove.
83
- * @param {'add' | 'extra'} type - Type of removal ('add' or 'extra').
84
- * @param {number} multi - Multiplier for experience generation.
85
- * @returns {Object} The updated user object.
99
+ * @param {UserEditor} user - The user object.
100
+ * @param {number} [extraExp] - Additional experience to remove.
101
+ * @param {'add' | 'extra'} [type] - Type of removal ('add' or 'extra').
102
+ * @param {number} [multi] - Multiplier for experience generation.
103
+ * @returns {UserResult} The updated user object.
86
104
  */
87
105
  remove(user: {
88
106
  exp: number;
89
107
  level: number;
90
108
  totalExp: any;
91
- }, extraExp?: number, type?: "add" | "extra", multi?: number): Object;
109
+ }, extraExp?: number, type?: "add" | "extra", multi?: number): {
110
+ exp: number;
111
+ level: number;
112
+ totalExp: number;
113
+ };
92
114
  }
@@ -11,10 +11,16 @@ class TinyLevelUp {
11
11
  this.giveExp = giveExp;
12
12
  this.expLevel = expLevel;
13
13
  }
14
+ /**
15
+ * @typedef {{ exp: number, level: number, totalExp: number }} UserResult
16
+ */
17
+ /**
18
+ * @typedef {{ exp: number, level: number, totalExp: any }} UserEditor
19
+ */
14
20
  /**
15
21
  * Validates and adjusts the user's level based on their current experience.
16
- * @param {{ exp: number, level: number, totalExp: any }} user - The user object containing experience and level properties.
17
- * @returns {Object} The updated user object.
22
+ * @param {UserEditor} user - The user object containing experience and level properties.
23
+ * @returns {UserResult} The updated user object.
18
24
  */
19
25
  expValidator(user) {
20
26
  let extraValue = 0;
@@ -51,7 +57,7 @@ class TinyLevelUp {
51
57
  }
52
58
  /**
53
59
  * Generates random experience points based on the configured multiplier.
54
- * @param {number} multi - A multiplier for the generated experience.
60
+ * @param {number} [multi] - A multiplier for the generated experience.
55
61
  * @returns {number} The generated experience points.
56
62
  */
57
63
  expGenerator(multi = 1) {
@@ -75,9 +81,9 @@ class TinyLevelUp {
75
81
  }
76
82
  /**
77
83
  * Sets the experience value for the user, adjusting their level if necessary.
78
- * @param {{ exp: number, level: number, totalExp: any }} user - The user object.
84
+ * @param {UserEditor} user - The user object.
79
85
  * @param {number} value - The new experience value to set.
80
- * @returns {Object} The updated user object.
86
+ * @returns {UserResult} The updated user object.
81
87
  */
82
88
  set(user, value) {
83
89
  user.exp = value;
@@ -87,11 +93,11 @@ class TinyLevelUp {
87
93
  }
88
94
  /**
89
95
  * Adds experience to the user, adjusting their level if necessary.
90
- * @param {{ exp: number, level: number, totalExp: any }} user - The user object.
91
- * @param {number} extraExp - Additional experience to be added.
92
- * @param {'add' | 'extra'} type - Type of addition ('add' or 'extra').
93
- * @param {number} multi - Multiplier for experience generation.
94
- * @returns {Object} The updated user object.
96
+ * @param {UserEditor} user - The user object.
97
+ * @param {number} [extraExp] - Additional experience to be added.
98
+ * @param {'add' | 'extra'} [type] - Type of addition ('add' or 'extra').
99
+ * @param {number} [multi] - Multiplier for experience generation.
100
+ * @returns {UserResult} The updated user object.
95
101
  */
96
102
  give(user, extraExp = 0, type = 'add', multi = 1) {
97
103
  if (type === 'add')
@@ -104,11 +110,11 @@ class TinyLevelUp {
104
110
  }
105
111
  /**
106
112
  * Removes experience from the user, adjusting their level if necessary.
107
- * @param {{ exp: number, level: number, totalExp: any }} user - The user object.
108
- * @param {number} extraExp - Experience to remove.
109
- * @param {'add' | 'extra'} type - Type of removal ('add' or 'extra').
110
- * @param {number} multi - Multiplier for experience generation.
111
- * @returns {Object} The updated user object.
113
+ * @param {UserEditor} user - The user object.
114
+ * @param {number} [extraExp] - Additional experience to remove.
115
+ * @param {'add' | 'extra'} [type] - Type of removal ('add' or 'extra').
116
+ * @param {number} [multi] - Multiplier for experience generation.
117
+ * @returns {UserResult} The updated user object.
112
118
  */
113
119
  remove(user, extraExp = 0, type = 'add', multi = 1) {
114
120
  if (type === 'add')
@@ -11,9 +11,9 @@ var userIP = require('../../http/userIP.cjs');
11
11
  * This middleware checks the user's IP address and allows or denies the socket connection based on whether
12
12
  * the IP is in the block list or not.
13
13
  *
14
- * @param {Object} io - The Socket.IO server instance.
15
- * @param {Object} ioCache - The cache object containing blocked IPs.
16
- * @param {Array} ioCache.blocklick - The list of blocked IP addresses.
14
+ * @param {Record<string, any>} io - The Socket.IO server instance.
15
+ * @param {Record<string, any>} ioCache - The cache object containing blocked IPs.
16
+ * @param {Array<*>} ioCache.blocklick - The list of blocked IP addresses.
17
17
  * @returns {void} This function does not return a value, it just sets the authorization logic for socket connections.
18
18
  */
19
19
  function install(io, ioCache) {
@@ -4,11 +4,9 @@
4
4
  * This middleware checks the user's IP address and allows or denies the socket connection based on whether
5
5
  * the IP is in the block list or not.
6
6
  *
7
- * @param {Object} io - The Socket.IO server instance.
8
- * @param {Object} ioCache - The cache object containing blocked IPs.
9
- * @param {Array} ioCache.blocklick - The list of blocked IP addresses.
7
+ * @param {Record<string, any>} io - The Socket.IO server instance.
8
+ * @param {Record<string, any>} ioCache - The cache object containing blocked IPs.
9
+ * @param {Array<*>} ioCache.blocklick - The list of blocked IP addresses.
10
10
  * @returns {void} This function does not return a value, it just sets the authorization logic for socket connections.
11
11
  */
12
- export default function install(io: Object, ioCache: {
13
- blocklick: any[];
14
- }): void;
12
+ export default function install(io: Record<string, any>, ioCache: Record<string, any>): void;
@@ -6,9 +6,9 @@ import userIp from '../../http/userIP.mjs';
6
6
  * This middleware checks the user's IP address and allows or denies the socket connection based on whether
7
7
  * the IP is in the block list or not.
8
8
  *
9
- * @param {Object} io - The Socket.IO server instance.
10
- * @param {Object} ioCache - The cache object containing blocked IPs.
11
- * @param {Array} ioCache.blocklick - The list of blocked IP addresses.
9
+ * @param {Record<string, any>} io - The Socket.IO server instance.
10
+ * @param {Record<string, any>} ioCache - The cache object containing blocked IPs.
11
+ * @param {Array<*>} ioCache.blocklick - The list of blocked IP addresses.
12
12
  * @returns {void} This function does not return a value, it just sets the authorization logic for socket connections.
13
13
  */
14
14
  export default function install(io, ioCache) {
@@ -26,10 +26,10 @@ setInterval(function () {
26
26
  * This function checks how many times an IP has attempted to interact with the socket.
27
27
  * If the attempts exceed a threshold, the IP is temporarily banned and disconnected.
28
28
  *
29
- * @param {Object} socket - The socket object representing the connection.
30
- * @param {Object} ioCache - The cache object that holds the blocklist and flood panel data.
31
- * @param {Array} ioCache.blocklick - The list of blocked IPs.
32
- * @param {Object} floodPanel - The object tracking flooding attempts and timeouts for each IP.
29
+ * @param {Record<string, any>} socket - The socket object representing the connection.
30
+ * @param {Record<string, any>} ioCache - The cache object that holds the blocklist and flood panel data.
31
+ * @param {Array<*>} ioCache.blocklick - The list of blocked IPs.
32
+ * @param {Record<string, any>} floodPanel - The object tracking flooding attempts and timeouts for each IP.
33
33
  * @returns {void} This function does not return anything, it modifies the floodPanel and blocklist.
34
34
  */
35
35
  function verify(socket, ioCache) {
@@ -4,12 +4,10 @@
4
4
  * This function checks how many times an IP has attempted to interact with the socket.
5
5
  * If the attempts exceed a threshold, the IP is temporarily banned and disconnected.
6
6
  *
7
- * @param {Object} socket - The socket object representing the connection.
8
- * @param {Object} ioCache - The cache object that holds the blocklist and flood panel data.
9
- * @param {Array} ioCache.blocklick - The list of blocked IPs.
10
- * @param {Object} floodPanel - The object tracking flooding attempts and timeouts for each IP.
7
+ * @param {Record<string, any>} socket - The socket object representing the connection.
8
+ * @param {Record<string, any>} ioCache - The cache object that holds the blocklist and flood panel data.
9
+ * @param {Array<*>} ioCache.blocklick - The list of blocked IPs.
10
+ * @param {Record<string, any>} floodPanel - The object tracking flooding attempts and timeouts for each IP.
11
11
  * @returns {void} This function does not return anything, it modifies the floodPanel and blocklist.
12
12
  */
13
- export default function verify(socket: Object, ioCache: {
14
- blocklick: any[];
15
- }): void;
13
+ export default function verify(socket: Record<string, any>, ioCache: Record<string, any>): void;
@@ -20,10 +20,10 @@ setInterval(function () {
20
20
  * This function checks how many times an IP has attempted to interact with the socket.
21
21
  * If the attempts exceed a threshold, the IP is temporarily banned and disconnected.
22
22
  *
23
- * @param {Object} socket - The socket object representing the connection.
24
- * @param {Object} ioCache - The cache object that holds the blocklist and flood panel data.
25
- * @param {Array} ioCache.blocklick - The list of blocked IPs.
26
- * @param {Object} floodPanel - The object tracking flooding attempts and timeouts for each IP.
23
+ * @param {Record<string, any>} socket - The socket object representing the connection.
24
+ * @param {Record<string, any>} ioCache - The cache object that holds the blocklist and flood panel data.
25
+ * @param {Array<*>} ioCache.blocklick - The list of blocked IPs.
26
+ * @param {Record<string, any>} floodPanel - The object tracking flooding attempts and timeouts for each IP.
27
27
  * @returns {void} This function does not return anything, it modifies the floodPanel and blocklist.
28
28
  */
29
29
  export default function verify(socket, ioCache) {
@@ -6,9 +6,9 @@
6
6
  * Handles the cookie session for a socket connection by simulating an Express request and response.
7
7
  * This function uses the provided session module to manage session data for the socket connection.
8
8
  *
9
- * @param {Object} socket - The socket object representing the connection.
9
+ * @param {Record<string, any>} socket - The socket object representing the connection.
10
10
  * @param {Function} sessionModule - The session module function, typically used with Express, that handles session logic.
11
- * @returns {Promise<Object>} A promise that resolves with the session object once the session is processed.
11
+ * @returns {Promise<Record<string, any>>} A promise that resolves with the session object once the session is processed.
12
12
  */
13
13
  function cookieSession(socket, sessionModule) {
14
14
  return new Promise((resolve) => {
@@ -2,8 +2,8 @@
2
2
  * Handles the cookie session for a socket connection by simulating an Express request and response.
3
3
  * This function uses the provided session module to manage session data for the socket connection.
4
4
  *
5
- * @param {Object} socket - The socket object representing the connection.
5
+ * @param {Record<string, any>} socket - The socket object representing the connection.
6
6
  * @param {Function} sessionModule - The session module function, typically used with Express, that handles session logic.
7
- * @returns {Promise<Object>} A promise that resolves with the session object once the session is processed.
7
+ * @returns {Promise<Record<string, any>>} A promise that resolves with the session object once the session is processed.
8
8
  */
9
- export default function cookieSession(socket: Object, sessionModule: Function): Promise<Object>;
9
+ export default function cookieSession(socket: Record<string, any>, sessionModule: Function): Promise<Record<string, any>>;
@@ -3,9 +3,9 @@
3
3
  * Handles the cookie session for a socket connection by simulating an Express request and response.
4
4
  * This function uses the provided session module to manage session data for the socket connection.
5
5
  *
6
- * @param {Object} socket - The socket object representing the connection.
6
+ * @param {Record<string, any>} socket - The socket object representing the connection.
7
7
  * @param {Function} sessionModule - The session module function, typically used with Express, that handles session logic.
8
- * @returns {Promise<Object>} A promise that resolves with the session object once the session is processed.
8
+ * @returns {Promise<Record<string, any>>} A promise that resolves with the session object once the session is processed.
9
9
  */
10
10
  export default function cookieSession(socket, sessionModule) {
11
11
  return new Promise((resolve) => {
@@ -9,10 +9,10 @@ var getUser = require('../firebase/discord/api/getUser.cjs');
9
9
  * Handles the Discord OAuth2 authentication for a user, stores user data in an in-memory cache,
10
10
  * and manages the user's socket connection and disconnection events.
11
11
  *
12
- * @param {Object} socket - The socket object representing the user's connection.
13
- * @param {Object} ioCache - The shared cache that stores user data and connections.
12
+ * @param {Record<string, any>} socket - The socket object representing the user's connection.
13
+ * @param {Record<string, any>} ioCache - The shared cache that stores user data and connections.
14
14
  * @param {string} token - The OAuth2 token used to fetch user data from Discord.
15
- * @returns {Promise<Object>} A promise that resolves with the user data and updates the cache.
15
+ * @returns {Promise<Record<string, any>>} A promise that resolves with the user data and updates the cache.
16
16
  */
17
17
  function discord(socket, ioCache, token) {
18
18
  return new Promise((resolve, reject) => {
@@ -2,9 +2,9 @@
2
2
  * Handles the Discord OAuth2 authentication for a user, stores user data in an in-memory cache,
3
3
  * and manages the user's socket connection and disconnection events.
4
4
  *
5
- * @param {Object} socket - The socket object representing the user's connection.
6
- * @param {Object} ioCache - The shared cache that stores user data and connections.
5
+ * @param {Record<string, any>} socket - The socket object representing the user's connection.
6
+ * @param {Record<string, any>} ioCache - The shared cache that stores user data and connections.
7
7
  * @param {string} token - The OAuth2 token used to fetch user data from Discord.
8
- * @returns {Promise<Object>} A promise that resolves with the user data and updates the cache.
8
+ * @returns {Promise<Record<string, any>>} A promise that resolves with the user data and updates the cache.
9
9
  */
10
- export default function discord(socket: Object, ioCache: Object, token: string): Promise<Object>;
10
+ export default function discord(socket: Record<string, any>, ioCache: Record<string, any>, token: string): Promise<Record<string, any>>;
@@ -4,10 +4,10 @@ import getUser from '../firebase/discord/api/getUser.mjs';
4
4
  * Handles the Discord OAuth2 authentication for a user, stores user data in an in-memory cache,
5
5
  * and manages the user's socket connection and disconnection events.
6
6
  *
7
- * @param {Object} socket - The socket object representing the user's connection.
8
- * @param {Object} ioCache - The shared cache that stores user data and connections.
7
+ * @param {Record<string, any>} socket - The socket object representing the user's connection.
8
+ * @param {Record<string, any>} ioCache - The shared cache that stores user data and connections.
9
9
  * @param {string} token - The OAuth2 token used to fetch user data from Discord.
10
- * @returns {Promise<Object>} A promise that resolves with the user data and updates the cache.
10
+ * @returns {Promise<Record<string, any>>} A promise that resolves with the user data and updates the cache.
11
11
  */
12
12
  export default function discord(socket, ioCache, token) {
13
13
  return new Promise((resolve, reject) => {
@@ -38,7 +38,7 @@ function getTimeDuration(timeData = new Date(), durationType = 'asSeconds', now
38
38
  * Includes proper reallocation of lower units into higher ones, ensuring consistent hierarchy.
39
39
  *
40
40
  * @param {number} totalSeconds - The total amount of seconds to convert.
41
- * @param {'seconds'|'minutes'|'hours'|'days'|'months'|'years'} level - The highest level to calculate and display.
41
+ * @param {'seconds'|'minutes'|'hours'|'days'|'months'|'years'} [level] - The highest level to calculate and display.
42
42
  * @param {string} [format='{time}'] - Output template with placeholders like {years}, {months}, {days}, {hours}, {minutes}, {seconds}, {time}, {total}.
43
43
  * @returns {string} The formatted timer string.
44
44
  */
@@ -12,7 +12,7 @@ export function getTimeDuration(timeData?: Date, durationType?: string, now?: Da
12
12
  * Includes proper reallocation of lower units into higher ones, ensuring consistent hierarchy.
13
13
  *
14
14
  * @param {number} totalSeconds - The total amount of seconds to convert.
15
- * @param {'seconds'|'minutes'|'hours'|'days'|'months'|'years'} level - The highest level to calculate and display.
15
+ * @param {'seconds'|'minutes'|'hours'|'days'|'months'|'years'} [level] - The highest level to calculate and display.
16
16
  * @param {string} [format='{time}'] - Output template with placeholders like {years}, {months}, {days}, {hours}, {minutes}, {seconds}, {time}, {total}.
17
17
  * @returns {string} The formatted timer string.
18
18
  */
@@ -33,7 +33,7 @@ export function getTimeDuration(timeData = new Date(), durationType = 'asSeconds
33
33
  * Includes proper reallocation of lower units into higher ones, ensuring consistent hierarchy.
34
34
  *
35
35
  * @param {number} totalSeconds - The total amount of seconds to convert.
36
- * @param {'seconds'|'minutes'|'hours'|'days'|'months'|'years'} level - The highest level to calculate and display.
36
+ * @param {'seconds'|'minutes'|'hours'|'days'|'months'|'years'} [level] - The highest level to calculate and display.
37
37
  * @param {string} [format='{time}'] - Output template with placeholders like {years}, {months}, {days}, {hours}, {minutes}, {seconds}, {time}, {total}.
38
38
  * @returns {string} The formatted timer string.
39
39
  */
@@ -6,7 +6,7 @@
6
6
  * @param {number} val1 - The first reference value (numerator in direct proportion, denominator in inverse).
7
7
  * @param {number} val2 - The second reference value (denominator in direct proportion, numerator in inverse).
8
8
  * @param {number} val3 - The third value (numerator in direct proportion, denominator in inverse).
9
- * @param {boolean} inverse - Whether the calculation should use inverse proportion (true for inverse, false for direct).
9
+ * @param {boolean} [inverse] - Whether the calculation should use inverse proportion (true for inverse, false for direct).
10
10
  * @returns {number} The result of the Rule of Three operation.
11
11
  *
12
12
  * Rule of Three Formula (Direct Proportion):
@@ -35,7 +35,7 @@
35
35
  * // Inverse proportion:
36
36
  * ruleOfThree.execute(2, 6, 3, true); // → 4
37
37
  */
38
- function ruleOfThree(val1, val2, val3, inverse) {
38
+ function ruleOfThree(val1, val2, val3, inverse = false) {
39
39
  return inverse ? Number(val1 * val2) / val3 : Number(val3 * val2) / val1;
40
40
  }
41
41
 
@@ -4,7 +4,7 @@
4
4
  * @param {number} val1 - The first reference value (numerator in direct proportion, denominator in inverse).
5
5
  * @param {number} val2 - The second reference value (denominator in direct proportion, numerator in inverse).
6
6
  * @param {number} val3 - The third value (numerator in direct proportion, denominator in inverse).
7
- * @param {boolean} inverse - Whether the calculation should use inverse proportion (true for inverse, false for direct).
7
+ * @param {boolean} [inverse] - Whether the calculation should use inverse proportion (true for inverse, false for direct).
8
8
  * @returns {number} The result of the Rule of Three operation.
9
9
  *
10
10
  * Rule of Three Formula (Direct Proportion):
@@ -33,7 +33,7 @@
33
33
  * // Inverse proportion:
34
34
  * ruleOfThree.execute(2, 6, 3, true); // → 4
35
35
  */
36
- export function ruleOfThree(val1: number, val2: number, val3: number, inverse: boolean): number;
36
+ export function ruleOfThree(val1: number, val2: number, val3: number, inverse?: boolean): number;
37
37
  /**
38
38
  * Calculates a percentage of a given base value.
39
39
  * @param {number} price - The base value.
@@ -4,7 +4,7 @@
4
4
  * @param {number} val1 - The first reference value (numerator in direct proportion, denominator in inverse).
5
5
  * @param {number} val2 - The second reference value (denominator in direct proportion, numerator in inverse).
6
6
  * @param {number} val3 - The third value (numerator in direct proportion, denominator in inverse).
7
- * @param {boolean} inverse - Whether the calculation should use inverse proportion (true for inverse, false for direct).
7
+ * @param {boolean} [inverse] - Whether the calculation should use inverse proportion (true for inverse, false for direct).
8
8
  * @returns {number} The result of the Rule of Three operation.
9
9
  *
10
10
  * Rule of Three Formula (Direct Proportion):
@@ -33,7 +33,7 @@
33
33
  * // Inverse proportion:
34
34
  * ruleOfThree.execute(2, 6, 3, true); // → 4
35
35
  */
36
- export function ruleOfThree(val1, val2, val3, inverse) {
36
+ export function ruleOfThree(val1, val2, val3, inverse = false) {
37
37
  return inverse ? Number(val1 * val2) / val3 : Number(val3 * val2) / val1;
38
38
  }
39
39
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tiny-essentials",
3
- "version": "1.3.0",
3
+ "version": "1.3.2",
4
4
  "description": "Collection of small, essential scripts designed to be used across various projects. These simple utilities are crafted for speed, ease of use, and versatility.",
5
5
  "scripts": {
6
6
  "test": "npm run test:mjs && npm run test:cjs && npm run test:js",