tiny-essentials 1.0.0

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 (302) hide show
  1. package/.github/FUNDING.yml +4 -0
  2. package/.github/workflows/node.js.yml +31 -0
  3. package/LICENSE +674 -0
  4. package/README.md +67 -0
  5. package/dist/TinyEssentials.min.js +1 -0
  6. package/dist/_virtual/_commonjsHelpers.cjs +7 -0
  7. package/dist/_virtual/common.cjs +5 -0
  8. package/dist/_virtual/index.cjs +9 -0
  9. package/dist/_virtual/index2.cjs +5 -0
  10. package/dist/_virtual/trace.cjs +5 -0
  11. package/dist/legacy/crypto/decrypt.cjs +57 -0
  12. package/dist/legacy/crypto/decrypt.d.mts +18 -0
  13. package/dist/legacy/crypto/decrypt.mjs +47 -0
  14. package/dist/legacy/crypto/default.cjs +23 -0
  15. package/dist/legacy/crypto/default.d.mts +35 -0
  16. package/dist/legacy/crypto/default.mjs +19 -0
  17. package/dist/legacy/crypto/encrypt.cjs +54 -0
  18. package/dist/legacy/crypto/encrypt.d.mts +19 -0
  19. package/dist/legacy/crypto/encrypt.mjs +46 -0
  20. package/dist/legacy/crypto/index.cjs +11 -0
  21. package/dist/legacy/crypto/index.d.mts +4 -0
  22. package/dist/legacy/crypto/index.mjs +6 -0
  23. package/dist/legacy/firebase/cookieSession.cjs +121 -0
  24. package/dist/legacy/firebase/cookieSession.d.mts +56 -0
  25. package/dist/legacy/firebase/cookieSession.mjs +114 -0
  26. package/dist/legacy/firebase/database/index.cjs +11 -0
  27. package/dist/legacy/firebase/database/index.d.mts +7 -0
  28. package/dist/legacy/firebase/database/index.mjs +7 -0
  29. package/dist/legacy/firebase/database/presence.cjs +131 -0
  30. package/dist/legacy/firebase/database/presence.d.mts +9 -0
  31. package/dist/legacy/firebase/database/presence.mjs +111 -0
  32. package/dist/legacy/firebase/database/saveAsync.cjs +147 -0
  33. package/dist/legacy/firebase/database/saveAsync.d.mts +54 -0
  34. package/dist/legacy/firebase/database/saveAsync.mjs +147 -0
  35. package/dist/legacy/firebase/databaseEscape.cjs +42 -0
  36. package/dist/legacy/firebase/databaseEscape.d.mts +11 -0
  37. package/dist/legacy/firebase/databaseEscape.mjs +37 -0
  38. package/dist/legacy/firebase/databaseLogger.cjs +258 -0
  39. package/dist/legacy/firebase/databaseLogger.d.mts +7 -0
  40. package/dist/legacy/firebase/databaseLogger.mjs +234 -0
  41. package/dist/legacy/firebase/discord/api/addGuildMember.cjs +71 -0
  42. package/dist/legacy/firebase/discord/api/addGuildMember.d.mts +38 -0
  43. package/dist/legacy/firebase/discord/api/addGuildMember.mjs +64 -0
  44. package/dist/legacy/firebase/discord/api/getGuildWidget.cjs +47 -0
  45. package/dist/legacy/firebase/discord/api/getGuildWidget.d.mts +17 -0
  46. package/dist/legacy/firebase/discord/api/getGuildWidget.mjs +43 -0
  47. package/dist/legacy/firebase/discord/api/getToken.cjs +67 -0
  48. package/dist/legacy/firebase/discord/api/getToken.d.mts +35 -0
  49. package/dist/legacy/firebase/discord/api/getToken.mjs +63 -0
  50. package/dist/legacy/firebase/discord/api/getUser.cjs +58 -0
  51. package/dist/legacy/firebase/discord/api/getUser.d.mts +27 -0
  52. package/dist/legacy/firebase/discord/api/getUser.mjs +54 -0
  53. package/dist/legacy/firebase/discord/api/getUserConnections.cjs +57 -0
  54. package/dist/legacy/firebase/discord/api/getUserConnections.d.mts +26 -0
  55. package/dist/legacy/firebase/discord/api/getUserConnections.mjs +53 -0
  56. package/dist/legacy/firebase/discord/api/getUserGuilds.cjs +56 -0
  57. package/dist/legacy/firebase/discord/api/getUserGuilds.d.mts +25 -0
  58. package/dist/legacy/firebase/discord/api/getUserGuilds.mjs +52 -0
  59. package/dist/legacy/firebase/discord/api/index.cjs +24 -0
  60. package/dist/legacy/firebase/discord/api/index.d.mts +19 -0
  61. package/dist/legacy/firebase/discord/api/index.mjs +20 -0
  62. package/dist/legacy/firebase/discord/api/refreshToken.cjs +77 -0
  63. package/dist/legacy/firebase/discord/api/refreshToken.d.mts +45 -0
  64. package/dist/legacy/firebase/discord/api/refreshToken.mjs +73 -0
  65. package/dist/legacy/firebase/discord/api/revokeToken.cjs +61 -0
  66. package/dist/legacy/firebase/discord/api/revokeToken.d.mts +29 -0
  67. package/dist/legacy/firebase/discord/api/revokeToken.mjs +58 -0
  68. package/dist/legacy/firebase/discord/config.cjs +21 -0
  69. package/dist/legacy/firebase/discord/config.d.mts +27 -0
  70. package/dist/legacy/firebase/discord/config.mjs +17 -0
  71. package/dist/legacy/firebase/discord/firebase_redirect/index.cjs +11 -0
  72. package/dist/legacy/firebase/discord/firebase_redirect/index.d.mts +7 -0
  73. package/dist/legacy/firebase/discord/firebase_redirect/index.mjs +7 -0
  74. package/dist/legacy/firebase/discord/firebase_redirect/login.cjs +110 -0
  75. package/dist/legacy/firebase/discord/firebase_redirect/login.d.mts +4 -0
  76. package/dist/legacy/firebase/discord/firebase_redirect/login.mjs +107 -0
  77. package/dist/legacy/firebase/discord/firebase_redirect/logout.cjs +100 -0
  78. package/dist/legacy/firebase/discord/firebase_redirect/logout.d.mts +4 -0
  79. package/dist/legacy/firebase/discord/firebase_redirect/logout.mjs +97 -0
  80. package/dist/legacy/firebase/discord/get/authURLGenerator.cjs +76 -0
  81. package/dist/legacy/firebase/discord/get/authURLGenerator.d.mts +23 -0
  82. package/dist/legacy/firebase/discord/get/authURLGenerator.mjs +67 -0
  83. package/dist/legacy/firebase/discord/get/cookie-session.cjs +32 -0
  84. package/dist/legacy/firebase/discord/get/cookie-session.d.mts +20 -0
  85. package/dist/legacy/firebase/discord/get/cookie-session.mjs +28 -0
  86. package/dist/legacy/firebase/discord/get/credentials.cjs +24 -0
  87. package/dist/legacy/firebase/discord/get/credentials.d.mts +19 -0
  88. package/dist/legacy/firebase/discord/get/credentials.mjs +20 -0
  89. package/dist/legacy/firebase/discord/get/errorValidator.cjs +60 -0
  90. package/dist/legacy/firebase/discord/get/errorValidator.d.mts +28 -0
  91. package/dist/legacy/firebase/discord/get/errorValidator.mjs +55 -0
  92. package/dist/legacy/firebase/discord/get/index.cjs +17 -0
  93. package/dist/legacy/firebase/discord/get/index.d.mts +13 -0
  94. package/dist/legacy/firebase/discord/get/index.mjs +13 -0
  95. package/dist/legacy/firebase/discord/get/randomAvatar.cjs +37 -0
  96. package/dist/legacy/firebase/discord/get/randomAvatar.d.mts +22 -0
  97. package/dist/legacy/firebase/discord/get/randomAvatar.mjs +30 -0
  98. package/dist/legacy/firebase/discord/http/index.cjs +15 -0
  99. package/dist/legacy/firebase/discord/http/index.d.mts +11 -0
  100. package/dist/legacy/firebase/discord/http/index.mjs +11 -0
  101. package/dist/legacy/firebase/discord/http/login.cjs +127 -0
  102. package/dist/legacy/firebase/discord/http/login.d.mts +21 -0
  103. package/dist/legacy/firebase/discord/http/login.mjs +123 -0
  104. package/dist/legacy/firebase/discord/http/logout.cjs +155 -0
  105. package/dist/legacy/firebase/discord/http/logout.d.mts +22 -0
  106. package/dist/legacy/firebase/discord/http/logout.mjs +143 -0
  107. package/dist/legacy/firebase/discord/http/redirect.cjs +188 -0
  108. package/dist/legacy/firebase/discord/http/redirect.d.mts +24 -0
  109. package/dist/legacy/firebase/discord/http/redirect.mjs +178 -0
  110. package/dist/legacy/firebase/discord/http/refreshToken.cjs +133 -0
  111. package/dist/legacy/firebase/discord/http/refreshToken.d.mts +24 -0
  112. package/dist/legacy/firebase/discord/http/refreshToken.mjs +121 -0
  113. package/dist/legacy/firebase/discord/index.cjs +19 -0
  114. package/dist/legacy/firebase/discord/index.d.mts +15 -0
  115. package/dist/legacy/firebase/discord/index.mjs +15 -0
  116. package/dist/legacy/firebase/discord/template/cookie-session.cjs +1430 -0
  117. package/dist/legacy/firebase/discord/template/cookie-session.d.mts +22 -0
  118. package/dist/legacy/firebase/discord/template/cookie-session.mjs +1159 -0
  119. package/dist/legacy/firebase/domainRedirect.cjs +35 -0
  120. package/dist/legacy/firebase/domainRedirect.d.mts +12 -0
  121. package/dist/legacy/firebase/domainRedirect.mjs +27 -0
  122. package/dist/legacy/firebase/escape.cjs +75 -0
  123. package/dist/legacy/firebase/escape.d.mts +17 -0
  124. package/dist/legacy/firebase/escape.mjs +58 -0
  125. package/dist/legacy/firebase/getDBAsync.cjs +33 -0
  126. package/dist/legacy/firebase/getDBAsync.d.mts +10 -0
  127. package/dist/legacy/firebase/getDBAsync.mjs +26 -0
  128. package/dist/legacy/firebase/getDBData.cjs +21 -0
  129. package/dist/legacy/firebase/getDBData.d.mts +1 -0
  130. package/dist/legacy/firebase/getDBData.mjs +17 -0
  131. package/dist/legacy/firebase/getDBValue.cjs +17 -0
  132. package/dist/legacy/firebase/getDBValue.d.mts +9 -0
  133. package/dist/legacy/firebase/getDBValue.mjs +14 -0
  134. package/dist/legacy/firebase/index.cjs +261 -0
  135. package/dist/legacy/firebase/index.d.mts +51 -0
  136. package/dist/legacy/firebase/index.mjs +234 -0
  137. package/dist/legacy/firebase/isEmulator.cjs +14 -0
  138. package/dist/legacy/firebase/isEmulator.d.mts +8 -0
  139. package/dist/legacy/firebase/isEmulator.mjs +10 -0
  140. package/dist/legacy/firebase/logger.cjs +137 -0
  141. package/dist/legacy/firebase/logger.d.mts +7 -0
  142. package/dist/legacy/firebase/logger.mjs +125 -0
  143. package/dist/legacy/firebase/mySQL.cjs +26 -0
  144. package/dist/legacy/firebase/mySQL.d.mts +10 -0
  145. package/dist/legacy/firebase/mySQL.mjs +22 -0
  146. package/dist/legacy/firebase/mysqlConnector/create.cjs +119 -0
  147. package/dist/legacy/firebase/mysqlConnector/create.d.mts +36 -0
  148. package/dist/legacy/firebase/mysqlConnector/create.mjs +109 -0
  149. package/dist/legacy/firebase/mysqlConnector/index.cjs +23 -0
  150. package/dist/legacy/firebase/mysqlConnector/index.d.mts +11 -0
  151. package/dist/legacy/firebase/mysqlConnector/index.mjs +16 -0
  152. package/dist/legacy/firebase/mysqlConnector/nextPrev.cjs +75 -0
  153. package/dist/legacy/firebase/mysqlConnector/nextPrev.d.mts +31 -0
  154. package/dist/legacy/firebase/mysqlConnector/nextPrev.mjs +63 -0
  155. package/dist/legacy/firebase/mysqlConnector/pagination.cjs +91 -0
  156. package/dist/legacy/firebase/mysqlConnector/pagination.d.mts +33 -0
  157. package/dist/legacy/firebase/mysqlConnector/pagination.mjs +87 -0
  158. package/dist/legacy/firebase/mysqlConnector/sameUser.cjs +28 -0
  159. package/dist/legacy/firebase/mysqlConnector/sameUser.d.mts +12 -0
  160. package/dist/legacy/firebase/mysqlConnector/sameUser.mjs +23 -0
  161. package/dist/legacy/firebase/transactionDBAsync.cjs +33 -0
  162. package/dist/legacy/firebase/transactionDBAsync.d.mts +11 -0
  163. package/dist/legacy/firebase/transactionDBAsync.mjs +27 -0
  164. package/dist/legacy/get/countObj.cjs +24 -0
  165. package/dist/legacy/get/countObj.d.mts +11 -0
  166. package/dist/legacy/get/countObj.mjs +21 -0
  167. package/dist/legacy/get/decimalColor.cjs +60 -0
  168. package/dist/legacy/get/decimalColor.d.mts +12 -0
  169. package/dist/legacy/get/decimalColor.mjs +54 -0
  170. package/dist/legacy/get/objType.cjs +43 -0
  171. package/dist/legacy/get/objType.d.mts +19 -0
  172. package/dist/legacy/get/objType.mjs +40 -0
  173. package/dist/legacy/get/pagination.cjs +100 -0
  174. package/dist/legacy/get/pagination.d.mts +25 -0
  175. package/dist/legacy/get/pagination.mjs +91 -0
  176. package/dist/legacy/get/queryUrlByName.cjs +31 -0
  177. package/dist/legacy/get/queryUrlByName.d.mts +20 -0
  178. package/dist/legacy/get/queryUrlByName.mjs +28 -0
  179. package/dist/legacy/get/queryUrlJSON.cjs +54 -0
  180. package/dist/legacy/get/queryUrlJSON.d.mts +23 -0
  181. package/dist/legacy/get/queryUrlJSON.mjs +57 -0
  182. package/dist/legacy/get/super_string_filter.cjs +97 -0
  183. package/dist/legacy/get/super_string_filter.d.mts +25 -0
  184. package/dist/legacy/get/super_string_filter.mjs +83 -0
  185. package/dist/legacy/get/versionCheck.cjs +49 -0
  186. package/dist/legacy/get/versionCheck.d.mts +17 -0
  187. package/dist/legacy/get/versionCheck.mjs +38 -0
  188. package/dist/legacy/http/HTTP-1.0.cjs +151 -0
  189. package/dist/legacy/http/HTTP-1.0.d.mts +8 -0
  190. package/dist/legacy/http/HTTP-1.0.mjs +136 -0
  191. package/dist/legacy/http/auth.cjs +70 -0
  192. package/dist/legacy/http/auth.d.mts +41 -0
  193. package/dist/legacy/http/auth.mjs +63 -0
  194. package/dist/legacy/http/check_domain.cjs +84 -0
  195. package/dist/legacy/http/check_domain.d.mts +10 -0
  196. package/dist/legacy/http/check_domain.mjs +82 -0
  197. package/dist/legacy/http/csrfTokenAnalyze.cjs +46 -0
  198. package/dist/legacy/http/csrfTokenAnalyze.d.mts +21 -0
  199. package/dist/legacy/http/csrfTokenAnalyze.mjs +40 -0
  200. package/dist/legacy/http/domainValidator.cjs +98 -0
  201. package/dist/legacy/http/domainValidator.d.mts +30 -0
  202. package/dist/legacy/http/domainValidator.mjs +82 -0
  203. package/dist/legacy/http/errorsCallback.cjs +55 -0
  204. package/dist/legacy/http/errorsCallback.d.mts +29 -0
  205. package/dist/legacy/http/errorsCallback.mjs +48 -0
  206. package/dist/legacy/http/fetch/json.cjs +48 -0
  207. package/dist/legacy/http/fetch/json.d.mts +22 -0
  208. package/dist/legacy/http/fetch/json.mjs +41 -0
  209. package/dist/legacy/http/fetch/text.cjs +47 -0
  210. package/dist/legacy/http/fetch/text.d.mts +21 -0
  211. package/dist/legacy/http/fetch/text.mjs +40 -0
  212. package/dist/legacy/http/fileCache.cjs +79 -0
  213. package/dist/legacy/http/fileCache.d.mts +35 -0
  214. package/dist/legacy/http/fileCache.mjs +70 -0
  215. package/dist/legacy/http/getDomainURL.cjs +59 -0
  216. package/dist/legacy/http/getDomainURL.d.mts +18 -0
  217. package/dist/legacy/http/getDomainURL.mjs +54 -0
  218. package/dist/legacy/http/userIP.cjs +59 -0
  219. package/dist/legacy/http/userIP.d.mts +21 -0
  220. package/dist/legacy/http/userIP.mjs +48 -0
  221. package/dist/legacy/index.cjs +122 -0
  222. package/dist/legacy/index.d.mts +89 -0
  223. package/dist/legacy/index.mjs +92 -0
  224. package/dist/legacy/libs/arraySortPositions.cjs +30 -0
  225. package/dist/legacy/libs/arraySortPositions.d.mts +16 -0
  226. package/dist/legacy/libs/arraySortPositions.mjs +27 -0
  227. package/dist/legacy/libs/capitalize.cjs +21 -0
  228. package/dist/legacy/libs/capitalize.d.mts +13 -0
  229. package/dist/legacy/libs/capitalize.mjs +17 -0
  230. package/dist/legacy/libs/convertBytes.cjs +64 -0
  231. package/dist/legacy/libs/convertBytes.d.mts +17 -0
  232. package/dist/legacy/libs/convertBytes.mjs +55 -0
  233. package/dist/legacy/libs/custom_module_loader.cjs +82 -0
  234. package/dist/legacy/libs/custom_module_loader.d.mts +5 -0
  235. package/dist/legacy/libs/custom_module_loader.mjs +79 -0
  236. package/dist/legacy/libs/dice.cjs +35 -0
  237. package/dist/legacy/libs/dice.d.mts +5 -0
  238. package/dist/legacy/libs/dice.mjs +31 -0
  239. package/dist/legacy/libs/markdown.cjs +85 -0
  240. package/dist/legacy/libs/markdown.d.mts +75 -0
  241. package/dist/legacy/libs/markdown.mjs +78 -0
  242. package/dist/legacy/libs/percentage.cjs +22 -0
  243. package/dist/legacy/libs/percentage.d.mts +4 -0
  244. package/dist/legacy/libs/percentage.mjs +19 -0
  245. package/dist/legacy/libs/regex/getLetter.cjs +22 -0
  246. package/dist/legacy/libs/regex/getLetter.d.mts +12 -0
  247. package/dist/legacy/libs/regex/getLetter.mjs +19 -0
  248. package/dist/legacy/libs/replaceAsync.cjs +32 -0
  249. package/dist/legacy/libs/replaceAsync.d.mts +15 -0
  250. package/dist/legacy/libs/replaceAsync.mjs +25 -0
  251. package/dist/legacy/libs/rule3.cjs +58 -0
  252. package/dist/legacy/libs/rule3.d.mts +5 -0
  253. package/dist/legacy/libs/rule3.mjs +54 -0
  254. package/dist/legacy/libs/userLevel.cjs +134 -0
  255. package/dist/legacy/libs/userLevel.d.mts +69 -0
  256. package/dist/legacy/libs/userLevel.mjs +123 -0
  257. package/dist/legacy/momentjs/getAge.cjs +28 -0
  258. package/dist/legacy/momentjs/getAge.d.mts +8 -0
  259. package/dist/legacy/momentjs/getAge.mjs +22 -0
  260. package/dist/legacy/momentjs/index.cjs +9 -0
  261. package/dist/legacy/momentjs/index.d.mts +3 -0
  262. package/dist/legacy/momentjs/index.mjs +3 -0
  263. package/dist/legacy/momentjs/timeDuration.cjs +29 -0
  264. package/dist/legacy/momentjs/timeDuration.d.mts +9 -0
  265. package/dist/legacy/momentjs/timeDuration.mjs +23 -0
  266. package/dist/legacy/socket.io/antiFlood/index.cjs +9 -0
  267. package/dist/legacy/socket.io/antiFlood/index.d.mts +3 -0
  268. package/dist/legacy/socket.io/antiFlood/index.mjs +3 -0
  269. package/dist/legacy/socket.io/antiFlood/install.cjs +32 -0
  270. package/dist/legacy/socket.io/antiFlood/install.d.mts +14 -0
  271. package/dist/legacy/socket.io/antiFlood/install.mjs +27 -0
  272. package/dist/legacy/socket.io/antiFlood/verify.cjs +87 -0
  273. package/dist/legacy/socket.io/antiFlood/verify.d.mts +15 -0
  274. package/dist/legacy/socket.io/antiFlood/verify.mjs +73 -0
  275. package/dist/legacy/socket.io/cookie-session.cjs +25 -0
  276. package/dist/legacy/socket.io/cookie-session.d.mts +9 -0
  277. package/dist/legacy/socket.io/cookie-session.mjs +20 -0
  278. package/dist/legacy/socket.io/discord.cjs +61 -0
  279. package/dist/legacy/socket.io/discord.d.mts +10 -0
  280. package/dist/legacy/socket.io/discord.mjs +52 -0
  281. package/dist/legacy/socket.io/index.cjs +13 -0
  282. package/dist/legacy/socket.io/index.d.mts +9 -0
  283. package/dist/legacy/socket.io/index.mjs +9 -0
  284. package/dist/v1/basics/array.cjs +31 -0
  285. package/dist/v1/basics/array.d.mts +10 -0
  286. package/dist/v1/basics/array.mjs +22 -0
  287. package/dist/v1/basics/clock.cjs +187 -0
  288. package/dist/v1/basics/clock.d.mts +37 -0
  289. package/dist/v1/basics/clock.mjs +152 -0
  290. package/dist/v1/basics/objFilter.cjs +55 -0
  291. package/dist/v1/basics/objFilter.d.mts +27 -0
  292. package/dist/v1/basics/objFilter.mjs +52 -0
  293. package/dist/v1/basics/simpleMath.cjs +88 -0
  294. package/dist/v1/basics/simpleMath.d.mts +54 -0
  295. package/dist/v1/basics/simpleMath.mjs +75 -0
  296. package/dist/v1/basics/text.cjs +34 -0
  297. package/dist/v1/basics/text.d.mts +20 -0
  298. package/dist/v1/basics/text.mjs +25 -0
  299. package/dist/v1/index.cjs +26 -0
  300. package/dist/v1/index.d.mts +15 -0
  301. package/dist/v1/index.mjs +8 -0
  302. package/package.json +72 -0
@@ -0,0 +1,87 @@
1
+ /**
2
+ * Executes a paginated query on the database, returning the result set along with pagination metadata.
3
+ *
4
+ * @async
5
+ * @param {Object} db - Database instance with a `.query(sql, params)` method.
6
+ * @param {Object} data - Query configuration options.
7
+ * @param {string} data.from - The table or view name to query from.
8
+ * @param {string} [data.where] - Optional WHERE clause without the keyword (e.g., `"status = 'active'"`).
9
+ * @param {Array} [data.params] - Optional parameters for the SQL query placeholders.
10
+ * @param {string} [data.select="*"] - Fields to select in the query.
11
+ * @param {string} data.order - SQL ORDER BY clause (e.g., `"created_at DESC"`).
12
+ * @param {number} [data.limit] - Number of rows per page.
13
+ * @param {number|string} [data.page] - Current page number or `'last'` to get the last page.
14
+ * @param {number} [data.count] - Optional total count override (skip count query if provided).
15
+ * @param {boolean} [data.count_rows=false] - Whether to include a row number for each result.
16
+ * @returns {Promise<Object>} Resolves with pagination metadata and result set.
17
+ * @returns {number} return.count - Total number of matched rows.
18
+ * @returns {Array} return.data - The paginated data from the query.
19
+ * @returns {number} return.pages - Total number of pages.
20
+ * @returns {number} return.page - Current page number after validation.
21
+ * @returns {number} return.start - Row offset used in the query.
22
+ */
23
+ export default async function pagination(db, data) {
24
+ // Create Where
25
+ if (data.where)
26
+ data.where = ' WHERE ' + data.where;
27
+ else
28
+ data.where = '';
29
+ // Values
30
+ let start = 0;
31
+ let page;
32
+ let pages;
33
+ let edit_count;
34
+ if (typeof data.page === 'number') {
35
+ // Get Count
36
+ if (!data.count) {
37
+ edit_count = await db.query(`SELECT COUNT(*) FROM ${data.from}${data.where}`, data.params);
38
+ edit_count = edit_count[0]['COUNT(*)'];
39
+ }
40
+ else
41
+ edit_count = data.count;
42
+ // Prepare Numbers
43
+ pages = Math.ceil(edit_count / data.limit);
44
+ // Default
45
+ page = data.page;
46
+ // Is Last
47
+ if (page === 'last')
48
+ page = pages;
49
+ // is NaN
50
+ else if (isNaN(page))
51
+ page = 1;
52
+ // Bigger
53
+ else if (page > pages)
54
+ page = pages;
55
+ // Smaller
56
+ else if (page < 1)
57
+ page = 1;
58
+ // Offset
59
+ if (page)
60
+ start = Number(page - 1) * data.limit;
61
+ else {
62
+ start = 0;
63
+ page = 1;
64
+ }
65
+ }
66
+ if (!data.select)
67
+ data.select = '*';
68
+ // Count Rows
69
+ let count_rows = {
70
+ select: '',
71
+ from: '',
72
+ };
73
+ if (data.count_rows)
74
+ count_rows = {
75
+ select: `(@row_number:=@row_number + 1) AS row_num, `,
76
+ from: `(SELECT @row_number:=${start}) AS row_number, `,
77
+ };
78
+ // Edits
79
+ let tiny_query = `SELECT ${count_rows.select}${data.select} FROM ${count_rows.from}${data.from}${data.where} ORDER BY ${data.order}`;
80
+ if (typeof data.limit === 'number')
81
+ tiny_query += ` LIMIT ${data.limit}`;
82
+ if (typeof data.page === 'number')
83
+ tiny_query += ` OFFSET ${start}`;
84
+ let edits = await db.query(tiny_query, data.params);
85
+ // Complete
86
+ return { count: edit_count, data: edits, pages: pages, page: page, start: start };
87
+ }
@@ -0,0 +1,28 @@
1
+ 'use strict';
2
+
3
+ var clone = require('clone');
4
+ var objType = require('../../get/objType.cjs');
5
+
6
+ /**
7
+ * Creates a deep clone of a login object and attaches the given database name to it,
8
+ * if the input types are valid.
9
+ *
10
+ * @param {string} database - The name of the database to associate with the user.
11
+ * @param {Object} login - The login object that contains user data.
12
+ * @param {Object} login.data - The nested data object inside the login object.
13
+ * @returns {Object|null} A cloned and modified login object with the database name attached, or null if invalid input.
14
+ */
15
+ function sameUser(database, login) {
16
+ // Validator
17
+ if (typeof database === 'string' && objType(login, 'object') && objType(login.data, 'object')) {
18
+ // Result
19
+ const result = clone(login);
20
+ result.data.database = database;
21
+ return result;
22
+ }
23
+
24
+ // Nope
25
+ else return null;
26
+ }
27
+
28
+ module.exports = sameUser;
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Creates a deep clone of a login object and attaches the given database name to it,
3
+ * if the input types are valid.
4
+ *
5
+ * @param {string} database - The name of the database to associate with the user.
6
+ * @param {Object} login - The login object that contains user data.
7
+ * @param {Object} login.data - The nested data object inside the login object.
8
+ * @returns {Object|null} A cloned and modified login object with the database name attached, or null if invalid input.
9
+ */
10
+ export default function sameUser(database: string, login: {
11
+ data: Object;
12
+ }): Object | null;
@@ -0,0 +1,23 @@
1
+ import clone from 'clone';
2
+ import objType from '../../get/objType.mjs';
3
+ /**
4
+ * Creates a deep clone of a login object and attaches the given database name to it,
5
+ * if the input types are valid.
6
+ *
7
+ * @param {string} database - The name of the database to associate with the user.
8
+ * @param {Object} login - The login object that contains user data.
9
+ * @param {Object} login.data - The nested data object inside the login object.
10
+ * @returns {Object|null} A cloned and modified login object with the database name attached, or null if invalid input.
11
+ */
12
+ export default function sameUser(database, login) {
13
+ // Validator
14
+ if (typeof database === 'string' && objType(login, 'object') && objType(login.data, 'object')) {
15
+ // Result
16
+ const result = clone(login);
17
+ result.data.database = database;
18
+ return result;
19
+ }
20
+ // Nope
21
+ else
22
+ return null;
23
+ }
@@ -0,0 +1,33 @@
1
+ 'use strict';
2
+
3
+ /**
4
+ * Executes a Firebase Realtime Database transaction asynchronously.
5
+ * This function uses the `transaction` method of Firebase to apply changes to the database.
6
+ * The provided callback is executed with the current value in the database, and the transaction
7
+ * is committed based on the result returned from the callback.
8
+ *
9
+ * @param {Object} data - The Firebase database reference object on which the transaction will be performed.
10
+ * @param {Function} callback - A function that accepts the current value of the data and returns the updated value.
11
+ * @returns {Promise} Resolves with the result of the transaction or rejects with an error if the transaction fails.
12
+ */
13
+ async function transactionDBAsync(data, callback) {
14
+ return new Promise(async function (resolve, reject) {
15
+ // Try
16
+ try {
17
+ // The Transaction
18
+ const result = await data.transaction(
19
+ function (current_value) {
20
+ return callback(current_value);
21
+ },
22
+ function (errorObject) {
23
+ reject(errorObject);
24
+ },
25
+ );
26
+ resolve(result);
27
+ } catch (err) {
28
+ reject(err);
29
+ }
30
+ });
31
+ }
32
+
33
+ module.exports = transactionDBAsync;
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Executes a Firebase Realtime Database transaction asynchronously.
3
+ * This function uses the `transaction` method of Firebase to apply changes to the database.
4
+ * The provided callback is executed with the current value in the database, and the transaction
5
+ * is committed based on the result returned from the callback.
6
+ *
7
+ * @param {Object} data - The Firebase database reference object on which the transaction will be performed.
8
+ * @param {Function} callback - A function that accepts the current value of the data and returns the updated value.
9
+ * @returns {Promise} Resolves with the result of the transaction or rejects with an error if the transaction fails.
10
+ */
11
+ export default function transactionDBAsync(data: Object, callback: Function): Promise<any>;
@@ -0,0 +1,27 @@
1
+ /**
2
+ * Executes a Firebase Realtime Database transaction asynchronously.
3
+ * This function uses the `transaction` method of Firebase to apply changes to the database.
4
+ * The provided callback is executed with the current value in the database, and the transaction
5
+ * is committed based on the result returned from the callback.
6
+ *
7
+ * @param {Object} data - The Firebase database reference object on which the transaction will be performed.
8
+ * @param {Function} callback - A function that accepts the current value of the data and returns the updated value.
9
+ * @returns {Promise} Resolves with the result of the transaction or rejects with an error if the transaction fails.
10
+ */
11
+ export default async function transactionDBAsync(data, callback) {
12
+ return new Promise(async function (resolve, reject) {
13
+ // Try
14
+ try {
15
+ // The Transaction
16
+ const result = await data.transaction(function (current_value) {
17
+ return callback(current_value);
18
+ }, function (errorObject) {
19
+ reject(errorObject);
20
+ });
21
+ resolve(result);
22
+ }
23
+ catch (err) {
24
+ reject(err);
25
+ }
26
+ });
27
+ }
@@ -0,0 +1,24 @@
1
+ 'use strict';
2
+
3
+ var objType = require('./objType.cjs');
4
+
5
+ /**
6
+ * Counts the number of elements or properties in an object or array.
7
+ *
8
+ * - If the input is an array, returns its length.
9
+ * - If it's a plain object, returns the number of its own enumerable properties.
10
+ * - Otherwise, returns 0.
11
+ *
12
+ * @param {*} obj - The input to count elements or properties from.
13
+ * @returns {number} The count of elements (array) or properties (object), or 0 if not applicable.
14
+ */
15
+ function countObj(obj) {
16
+ // Is Array
17
+ if (Array.isArray(obj)) return obj.length;
18
+ // Object
19
+ else if (objType(obj, 'object')) return Object.keys(obj).length;
20
+ // Nothing
21
+ return 0;
22
+ }
23
+
24
+ module.exports = countObj;
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Counts the number of elements or properties in an object or array.
3
+ *
4
+ * - If the input is an array, returns its length.
5
+ * - If it's a plain object, returns the number of its own enumerable properties.
6
+ * - Otherwise, returns 0.
7
+ *
8
+ * @param {*} obj - The input to count elements or properties from.
9
+ * @returns {number} The count of elements (array) or properties (object), or 0 if not applicable.
10
+ */
11
+ export default function countObj(obj: any): number;
@@ -0,0 +1,21 @@
1
+ import objType from './objType.mjs';
2
+ /**
3
+ * Counts the number of elements or properties in an object or array.
4
+ *
5
+ * - If the input is an array, returns its length.
6
+ * - If it's a plain object, returns the number of its own enumerable properties.
7
+ * - Otherwise, returns 0.
8
+ *
9
+ * @param {*} obj - The input to count elements or properties from.
10
+ * @returns {number} The count of elements (array) or properties (object), or 0 if not applicable.
11
+ */
12
+ export default function countObj(obj) {
13
+ // Is Array
14
+ if (Array.isArray(obj))
15
+ return obj.length;
16
+ // Object
17
+ else if (objType(obj, 'object'))
18
+ return Object.keys(obj).length;
19
+ // Nothing
20
+ return 0;
21
+ }
@@ -0,0 +1,60 @@
1
+ 'use strict';
2
+
3
+ var tinycolor = require('tinycolor2');
4
+
5
+ /**
6
+ * Combines RGB values into a single decimal color.
7
+ *
8
+ * @private
9
+ * @param {number} r - Red component (0–255).
10
+ * @param {number} g - Green component (0–255).
11
+ * @param {number} b - Blue component (0–255).
12
+ * @returns {number} The combined decimal color value.
13
+ */
14
+ function combineRGB(r, g, b) {
15
+ return (r << 16) | (g << 8) | b;
16
+ }
17
+
18
+ /**
19
+ * Converts a CSS color string (hex, rgb, hsl, etc.) to a decimal color value.
20
+ *
21
+ * - If the input is a valid color string, it returns the decimal RGB representation (e.g. 16729344 for `#ff6600`).
22
+ * - If invalid, returns `0`.
23
+ * - If the input is already a number and valid, returns it unchanged.
24
+ *
25
+ * @param {string|number} color - The color input (e.g. "#ff6600", "rgb(255, 102, 0)", or a decimal number).
26
+ * @param {function} [errCallback] - Optional callback to handle parsing errors.
27
+ * @returns {number} The decimal representation of the color, or 0 if invalid.
28
+ */
29
+ function decimalColor(color, errCallback) {
30
+ // Is String
31
+ if (typeof color === 'string') {
32
+ // Prepare Color
33
+ try {
34
+ // Get Color Manager
35
+ color = tinycolor(color);
36
+
37
+ // Validate
38
+ if (color.isValid()) {
39
+ // Convert
40
+ color = color.toRgb();
41
+ color = combineRGB(color.r, color.g, color.b);
42
+ }
43
+
44
+ // Nope
45
+ else color = 0;
46
+ } catch (err) {
47
+ // Error
48
+ if (typeof errCallback === 'function') errCallback(err);
49
+ color = 0;
50
+ }
51
+ }
52
+
53
+ // Fix Color Number
54
+ if (typeof color !== 'number' || isNaN(color) || !isFinite(color) || color < 0) color = 0;
55
+
56
+ // Return the Color Value
57
+ return color;
58
+ }
59
+
60
+ module.exports = decimalColor;
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Converts a CSS color string (hex, rgb, hsl, etc.) to a decimal color value.
3
+ *
4
+ * - If the input is a valid color string, it returns the decimal RGB representation (e.g. 16729344 for `#ff6600`).
5
+ * - If invalid, returns `0`.
6
+ * - If the input is already a number and valid, returns it unchanged.
7
+ *
8
+ * @param {string|number} color - The color input (e.g. "#ff6600", "rgb(255, 102, 0)", or a decimal number).
9
+ * @param {function} [errCallback] - Optional callback to handle parsing errors.
10
+ * @returns {number} The decimal representation of the color, or 0 if invalid.
11
+ */
12
+ export default function decimalColor(color: string | number, errCallback?: Function): number;
@@ -0,0 +1,54 @@
1
+ import tinycolor from 'tinycolor2';
2
+ /**
3
+ * Combines RGB values into a single decimal color.
4
+ *
5
+ * @private
6
+ * @param {number} r - Red component (0–255).
7
+ * @param {number} g - Green component (0–255).
8
+ * @param {number} b - Blue component (0–255).
9
+ * @returns {number} The combined decimal color value.
10
+ */
11
+ function combineRGB(r, g, b) {
12
+ return (r << 16) | (g << 8) | b;
13
+ }
14
+ /**
15
+ * Converts a CSS color string (hex, rgb, hsl, etc.) to a decimal color value.
16
+ *
17
+ * - If the input is a valid color string, it returns the decimal RGB representation (e.g. 16729344 for `#ff6600`).
18
+ * - If invalid, returns `0`.
19
+ * - If the input is already a number and valid, returns it unchanged.
20
+ *
21
+ * @param {string|number} color - The color input (e.g. "#ff6600", "rgb(255, 102, 0)", or a decimal number).
22
+ * @param {function} [errCallback] - Optional callback to handle parsing errors.
23
+ * @returns {number} The decimal representation of the color, or 0 if invalid.
24
+ */
25
+ export default function decimalColor(color, errCallback) {
26
+ // Is String
27
+ if (typeof color === 'string') {
28
+ // Prepare Color
29
+ try {
30
+ // Get Color Manager
31
+ color = tinycolor(color);
32
+ // Validate
33
+ if (color.isValid()) {
34
+ // Convert
35
+ color = color.toRgb();
36
+ color = combineRGB(color.r, color.g, color.b);
37
+ }
38
+ // Nope
39
+ else
40
+ color = 0;
41
+ }
42
+ catch (err) {
43
+ // Error
44
+ if (typeof errCallback === 'function')
45
+ errCallback(err);
46
+ color = 0;
47
+ }
48
+ }
49
+ // Fix Color Number
50
+ if (typeof color !== 'number' || isNaN(color) || !isFinite(color) || color < 0)
51
+ color = 0;
52
+ // Return the Color Value
53
+ return color;
54
+ }
@@ -0,0 +1,43 @@
1
+ 'use strict';
2
+
3
+ /**
4
+ * Checks the internal type of an object using `Object.prototype.toString`.
5
+ *
6
+ * - If `type` is provided, returns `true` if it matches the object's internal type (case-insensitive).
7
+ * - If `type` is omitted, returns the object's internal type as a lowercase string.
8
+ *
9
+ * Examples:
10
+ * ```js
11
+ * objType([], 'array'); // true
12
+ * objType({}, 'object'); // true
13
+ * objType('hello'); // "string"
14
+ * objType(undefined); // null
15
+ * ```
16
+ *
17
+ * @param {*} obj - The value to check the type of.
18
+ * @param {string} [type] - Optional string to compare the object's type against.
19
+ * @returns {boolean|string|null} Returns true/false if checking, or type string/null if querying.
20
+ */
21
+ function objType(obj, type) {
22
+ // Is Defined
23
+ if (typeof obj !== 'undefined') {
24
+ // Check Obj Type
25
+ if (typeof type === 'string') {
26
+ if (Object.prototype.toString.call(obj).toLowerCase() === `[object ${type}]`) return true;
27
+ else return false;
28
+ }
29
+
30
+ // Get Obj Type
31
+ else {
32
+ // Result
33
+ const result = Object.prototype.toString.call(obj).toLowerCase();
34
+ // Send Result
35
+ return result.substring(8, result.length - 1);
36
+ }
37
+ }
38
+
39
+ // Nope
40
+ else return null;
41
+ }
42
+
43
+ module.exports = objType;
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Checks the internal type of an object using `Object.prototype.toString`.
3
+ *
4
+ * - If `type` is provided, returns `true` if it matches the object's internal type (case-insensitive).
5
+ * - If `type` is omitted, returns the object's internal type as a lowercase string.
6
+ *
7
+ * Examples:
8
+ * ```js
9
+ * objType([], 'array'); // true
10
+ * objType({}, 'object'); // true
11
+ * objType('hello'); // "string"
12
+ * objType(undefined); // null
13
+ * ```
14
+ *
15
+ * @param {*} obj - The value to check the type of.
16
+ * @param {string} [type] - Optional string to compare the object's type against.
17
+ * @returns {boolean|string|null} Returns true/false if checking, or type string/null if querying.
18
+ */
19
+ export default function objType(obj: any, type?: string): boolean | string | null;
@@ -0,0 +1,40 @@
1
+ /**
2
+ * Checks the internal type of an object using `Object.prototype.toString`.
3
+ *
4
+ * - If `type` is provided, returns `true` if it matches the object's internal type (case-insensitive).
5
+ * - If `type` is omitted, returns the object's internal type as a lowercase string.
6
+ *
7
+ * Examples:
8
+ * ```js
9
+ * objType([], 'array'); // true
10
+ * objType({}, 'object'); // true
11
+ * objType('hello'); // "string"
12
+ * objType(undefined); // null
13
+ * ```
14
+ *
15
+ * @param {*} obj - The value to check the type of.
16
+ * @param {string} [type] - Optional string to compare the object's type against.
17
+ * @returns {boolean|string|null} Returns true/false if checking, or type string/null if querying.
18
+ */
19
+ export default function objType(obj, type) {
20
+ // Is Defined
21
+ if (typeof obj !== 'undefined') {
22
+ // Check Obj Type
23
+ if (typeof type === 'string') {
24
+ if (Object.prototype.toString.call(obj).toLowerCase() === `[object ${type}]`)
25
+ return true;
26
+ else
27
+ return false;
28
+ }
29
+ // Get Obj Type
30
+ else {
31
+ // Result
32
+ const result = Object.prototype.toString.call(obj).toLowerCase();
33
+ // Send Result
34
+ return result.substring(8, result.length - 1);
35
+ }
36
+ }
37
+ // Nope
38
+ else
39
+ return null;
40
+ }
@@ -0,0 +1,100 @@
1
+ 'use strict';
2
+
3
+ var queryUrlJSON = require('./queryUrlJSON.cjs');
4
+
5
+ /**
6
+ * Generates pagination metadata for a given query and current page.
7
+ * It builds a list of pages to display and determines whether "next" and "previous" buttons should be shown.
8
+ * The resulting object can be used to render a pagination UI.
9
+ *
10
+ * @param {string} query - The base query string to be appended to URLs (without `?` or `&`).
11
+ * @param {number} page - The current page number.
12
+ * @param {number} total - The total number of pages.
13
+ * @param {string} [url=''] - The base URL to which pagination parameters will be added.
14
+ * @param {string} [extraClass=''] - Additional class name for styling the pagination container.
15
+ * @param {string} [extraClass2=''] - Additional class name for individual page links.
16
+ *
17
+ * @returns {Object} Pagination metadata including:
18
+ * - `url` {string} - The updated URL prefix to use for each page link.
19
+ * - `extraClass` {string} - Additional class name passed through.
20
+ * - `extraClass2` {string} - Additional class name passed through.
21
+ * - `page` {number} - The current page.
22
+ * - `pagination` {number[]} - An array of page numbers to be displayed.
23
+ * - `previous` {boolean} - Whether there are previous pages.
24
+ * - `next` {boolean} - Whether there are next pages.
25
+ * - `firstPagination` {boolean} - `true` if page 1 is not in the visible pagination and should be shown separately.
26
+ * - `lastPagination` {boolean} - `true` if the last page is not in the visible pagination and should be shown separately.
27
+ * - `pages` {number} - Total number of pages.
28
+ */
29
+ function pagination(
30
+ query,
31
+ page,
32
+ total,
33
+ url = '',
34
+ extraClass = '',
35
+ extraClass2 = '',
36
+ ) {
37
+ // Fix URL
38
+ if (url) {
39
+ // Final URL Result
40
+ const finalURLResult = function (sqT = '') {
41
+ if (query) return sqT + query + '&page=';
42
+ else return 'page=';
43
+ };
44
+
45
+ // Param Fixed
46
+ const params = queryUrlJSON(url);
47
+ if (Object.keys(params).length > 0) {
48
+ if (params.page) {
49
+ url = url
50
+ .replace(finalURLResult('&') + params.page, '')
51
+ .replace('?' + query + '=' + params.page, '?')
52
+ .replace('?&', '?');
53
+
54
+ if (Object.keys(params).length === 1) url += finalURLResult();
55
+ else url += finalURLResult('&');
56
+ } else url += finalURLResult('&');
57
+ } else url += finalURLResult('?');
58
+ }
59
+
60
+ // Pagination
61
+
62
+ const pagination = [];
63
+ const data = {
64
+ url: url,
65
+ extraClass: extraClass,
66
+ extraClass2: extraClass2,
67
+ };
68
+
69
+ data.next = false;
70
+ data.previous = false;
71
+ for (let i = page - 1; i > page - 5; i--) {
72
+ if (i > 0) {
73
+ pagination.push(i);
74
+ data.previous = true;
75
+ }
76
+ }
77
+ pagination.reverse();
78
+ pagination.push(page);
79
+ for (let i = page + 1; i < page + 5; i++) {
80
+ if (i <= total) {
81
+ pagination.push(i);
82
+ data.next = true;
83
+ }
84
+ }
85
+
86
+ // Build Data and send it
87
+ data.page = page;
88
+ data.pagination = pagination;
89
+
90
+ if (pagination.indexOf(1) < 0) data.firstPagination = true;
91
+ else data.firstPagination = false;
92
+ if (pagination.indexOf(total) < 0) data.lastPagination = true;
93
+ else data.lastPagination = false;
94
+
95
+ data.pages = total;
96
+
97
+ return data;
98
+ }
99
+
100
+ module.exports = pagination;
@@ -0,0 +1,25 @@
1
+ /**
2
+ * Generates pagination metadata for a given query and current page.
3
+ * It builds a list of pages to display and determines whether "next" and "previous" buttons should be shown.
4
+ * The resulting object can be used to render a pagination UI.
5
+ *
6
+ * @param {string} query - The base query string to be appended to URLs (without `?` or `&`).
7
+ * @param {number} page - The current page number.
8
+ * @param {number} total - The total number of pages.
9
+ * @param {string} [url=''] - The base URL to which pagination parameters will be added.
10
+ * @param {string} [extraClass=''] - Additional class name for styling the pagination container.
11
+ * @param {string} [extraClass2=''] - Additional class name for individual page links.
12
+ *
13
+ * @returns {Object} Pagination metadata including:
14
+ * - `url` {string} - The updated URL prefix to use for each page link.
15
+ * - `extraClass` {string} - Additional class name passed through.
16
+ * - `extraClass2` {string} - Additional class name passed through.
17
+ * - `page` {number} - The current page.
18
+ * - `pagination` {number[]} - An array of page numbers to be displayed.
19
+ * - `previous` {boolean} - Whether there are previous pages.
20
+ * - `next` {boolean} - Whether there are next pages.
21
+ * - `firstPagination` {boolean} - `true` if page 1 is not in the visible pagination and should be shown separately.
22
+ * - `lastPagination` {boolean} - `true` if the last page is not in the visible pagination and should be shown separately.
23
+ * - `pages` {number} - Total number of pages.
24
+ */
25
+ export default function pagination(query: string, page: number, total: number, url?: string, extraClass?: string, extraClass2?: string): Object;