tiny-essentials 1.3.2 → 1.5.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.
- package/dist/TinyBasicsEs.js +45 -22
- package/dist/TinyBasicsEs.min.js +1 -1
- package/dist/TinyEssentials.js +223 -22
- package/dist/TinyEssentials.min.js +1 -1
- package/dist/TinyPromiseQueue.js +214 -0
- package/dist/TinyPromiseQueue.min.js +1 -0
- package/dist/legacy/crypto/decrypt.d.mts +1 -0
- package/dist/legacy/crypto/default.d.mts +1 -0
- package/dist/legacy/crypto/encrypt.d.mts +1 -0
- package/dist/legacy/crypto/index.d.mts +1 -0
- package/dist/legacy/firebase/cookieSession.d.mts +1 -0
- package/dist/legacy/firebase/database/index.d.mts +1 -0
- package/dist/legacy/firebase/database/presence.d.mts +1 -0
- package/dist/legacy/firebase/database/saveAsync.d.mts +1 -0
- package/dist/legacy/firebase/databaseEscape.d.mts +1 -0
- package/dist/legacy/firebase/databaseLogger.d.mts +1 -0
- package/dist/legacy/firebase/discord/api/addGuildMember.d.mts +1 -0
- package/dist/legacy/firebase/discord/api/getGuildWidget.d.mts +1 -0
- package/dist/legacy/firebase/discord/api/getToken.d.mts +1 -0
- package/dist/legacy/firebase/discord/api/getUser.d.mts +1 -0
- package/dist/legacy/firebase/discord/api/getUserConnections.d.mts +1 -0
- package/dist/legacy/firebase/discord/api/getUserGuilds.d.mts +1 -0
- package/dist/legacy/firebase/discord/api/index.d.mts +1 -0
- package/dist/legacy/firebase/discord/api/refreshToken.d.mts +1 -0
- package/dist/legacy/firebase/discord/api/revokeToken.d.mts +1 -0
- package/dist/legacy/firebase/discord/config.d.mts +1 -0
- package/dist/legacy/firebase/discord/firebase_redirect/index.d.mts +1 -0
- package/dist/legacy/firebase/discord/firebase_redirect/login.d.mts +1 -0
- package/dist/legacy/firebase/discord/firebase_redirect/logout.d.mts +1 -0
- package/dist/legacy/firebase/discord/get/authURLGenerator.d.mts +1 -0
- package/dist/legacy/firebase/discord/get/cookie-session.d.mts +1 -0
- package/dist/legacy/firebase/discord/get/credentials.d.mts +1 -0
- package/dist/legacy/firebase/discord/get/errorValidator.d.mts +1 -0
- package/dist/legacy/firebase/discord/get/index.d.mts +1 -0
- package/dist/legacy/firebase/discord/get/randomAvatar.d.mts +1 -0
- package/dist/legacy/firebase/discord/http/index.d.mts +1 -0
- package/dist/legacy/firebase/discord/http/login.d.mts +1 -0
- package/dist/legacy/firebase/discord/http/logout.d.mts +1 -0
- package/dist/legacy/firebase/discord/http/redirect.d.mts +1 -0
- package/dist/legacy/firebase/discord/http/refreshToken.d.mts +1 -0
- package/dist/legacy/firebase/discord/index.d.mts +1 -0
- package/dist/legacy/firebase/discord/template/cookie-session.d.mts +1 -0
- package/dist/legacy/firebase/domainRedirect.d.mts +1 -0
- package/dist/legacy/firebase/escape.d.mts +1 -0
- package/dist/legacy/firebase/getDBAsync.d.mts +1 -0
- package/dist/legacy/firebase/getDBData.d.mts +1 -0
- package/dist/legacy/firebase/getDBValue.d.mts +1 -0
- package/dist/legacy/firebase/index.d.mts +1 -0
- package/dist/legacy/firebase/isEmulator.d.mts +1 -0
- package/dist/legacy/firebase/logger.d.mts +1 -0
- package/dist/legacy/firebase/mySQL.d.mts +1 -0
- package/dist/legacy/firebase/mysqlConnector/create.d.mts +1 -0
- package/dist/legacy/firebase/mysqlConnector/index.d.mts +1 -0
- package/dist/legacy/firebase/mysqlConnector/nextPrev.d.mts +1 -0
- package/dist/legacy/firebase/mysqlConnector/pagination.d.mts +1 -0
- package/dist/legacy/firebase/mysqlConnector/sameUser.d.mts +1 -0
- package/dist/legacy/firebase/transactionDBAsync.d.mts +1 -0
- package/dist/legacy/get/countObj.d.mts +1 -0
- package/dist/legacy/get/decimalColor.d.mts +1 -0
- package/dist/legacy/get/objType.d.mts +1 -0
- package/dist/legacy/get/pagination.d.mts +1 -0
- package/dist/legacy/get/queryUrlByName.d.mts +1 -0
- package/dist/legacy/get/queryUrlJSON.d.mts +1 -0
- package/dist/legacy/get/super_string_filter.d.mts +1 -0
- package/dist/legacy/get/versionCheck.d.mts +1 -0
- package/dist/legacy/http/HTTP-1.0.d.mts +1 -0
- package/dist/legacy/http/auth.d.mts +1 -0
- package/dist/legacy/http/check_domain.d.mts +1 -0
- package/dist/legacy/http/csrfTokenAnalyze.d.mts +1 -0
- package/dist/legacy/http/domainValidator.d.mts +1 -0
- package/dist/legacy/http/errorsCallback.d.mts +1 -0
- package/dist/legacy/http/fetch/json.d.mts +1 -0
- package/dist/legacy/http/fetch/text.d.mts +1 -0
- package/dist/legacy/http/fileCache.d.mts +1 -0
- package/dist/legacy/http/getDomainURL.d.mts +1 -0
- package/dist/legacy/http/userIP.d.mts +1 -0
- package/dist/legacy/index.d.mts +1 -0
- package/dist/legacy/libs/arraySortPositions.d.mts +1 -0
- package/dist/legacy/libs/capitalize.d.mts +1 -0
- package/dist/legacy/libs/convertBytes.d.mts +1 -0
- package/dist/legacy/libs/custom_module_loader.d.mts +1 -0
- package/dist/legacy/libs/dice.d.mts +1 -0
- package/dist/legacy/libs/markdown.d.mts +1 -0
- package/dist/legacy/libs/percentage.d.mts +1 -0
- package/dist/legacy/libs/regex/getLetter.d.mts +1 -0
- package/dist/legacy/libs/replaceAsync.d.mts +1 -0
- package/dist/legacy/libs/rule3.d.mts +1 -0
- package/dist/legacy/libs/userLevel.d.mts +1 -0
- package/dist/legacy/momentjs/getAge.d.mts +1 -0
- package/dist/legacy/momentjs/index.d.mts +1 -0
- package/dist/legacy/momentjs/timeDuration.d.mts +1 -0
- package/dist/legacy/socket.io/antiFlood/index.d.mts +1 -0
- package/dist/legacy/socket.io/antiFlood/install.d.mts +1 -0
- package/dist/legacy/socket.io/antiFlood/verify.d.mts +1 -0
- package/dist/legacy/socket.io/cookie-session.d.mts +1 -0
- package/dist/legacy/socket.io/discord.d.mts +1 -0
- package/dist/legacy/socket.io/index.d.mts +1 -0
- package/dist/v1/basics/array.d.mts +1 -0
- package/dist/v1/basics/clock.d.mts +1 -0
- package/dist/v1/basics/index.d.mts +1 -0
- package/dist/v1/basics/objFilter.cjs +46 -22
- package/dist/v1/basics/objFilter.d.mts +13 -2
- package/dist/v1/basics/objFilter.mjs +43 -22
- package/dist/v1/basics/simpleMath.d.mts +1 -0
- package/dist/v1/basics/text.d.mts +1 -0
- package/dist/v1/build/TinyLevelUp.d.mts +1 -0
- package/dist/v1/build/TinyPromiseQueue.cjs +7 -0
- package/dist/v1/build/TinyPromiseQueue.d.mts +3 -0
- package/dist/v1/build/TinyPromiseQueue.mjs +2 -0
- package/dist/v1/index.cjs +3 -0
- package/dist/v1/index.d.mts +4 -1
- package/dist/v1/index.mjs +3 -2
- package/dist/v1/libs/TinyPromiseQueue.cjs +175 -0
- package/dist/v1/libs/TinyPromiseQueue.d.mts +63 -0
- package/dist/v1/libs/TinyPromiseQueue.mjs +159 -0
- package/docs/README.md +5 -0
- package/docs/basics/asyncReplace.md +39 -0
- package/docs/basics/objFilter.md +33 -0
- package/docs/libs/TinyLevelUp.md +108 -0
- package/docs/libs/TinyPromiseQueue.md +126 -0
- package/package.json +4 -2
|
@@ -8,3 +8,4 @@
|
|
|
8
8
|
* @throws {Error} If an error occurs during the database operation, the promise will be rejected with the error.
|
|
9
9
|
*/
|
|
10
10
|
export default function getDBAsync(data: firebase.database.Reference, type?: string): Promise<firebase.database.DataSnapshot>;
|
|
11
|
+
//# sourceMappingURL=getDBAsync.d.mts.map
|
|
@@ -9,3 +9,4 @@
|
|
|
9
9
|
* @returns {Promise} Resolves with the result of the transaction or rejects with an error if the transaction fails.
|
|
10
10
|
*/
|
|
11
11
|
export default function transactionDBAsync(data: Record<string, any>, callback: Function): Promise<any>;
|
|
12
|
+
//# sourceMappingURL=transactionDBAsync.d.mts.map
|
|
@@ -6,3 +6,4 @@ declare namespace http_base {
|
|
|
6
6
|
function send(res: import("express").Response, http_code: number, callback?: (arg0: number) => void): any;
|
|
7
7
|
function sendAsync(res: import("express").Response, http_code: number, callback?: (arg0: number) => Promise<any>): Promise<any>;
|
|
8
8
|
}
|
|
9
|
+
//# sourceMappingURL=HTTP-1.0.d.mts.map
|
package/dist/legacy/index.d.mts
CHANGED
|
@@ -3,3 +3,4 @@ declare namespace custom_module_manager {
|
|
|
3
3
|
function validator(custom_modules: Record<string, any>, type: string): boolean;
|
|
4
4
|
function run(custom_modules: Object | Function[], db_prepare: any, hookType: string, options?: Record<string, any>): Promise<void>;
|
|
5
5
|
}
|
|
6
|
+
//# sourceMappingURL=custom_module_loader.d.mts.map
|
|
@@ -7,3 +7,4 @@
|
|
|
7
7
|
* @returns {number|null} The calculated duration in the specified unit (default: seconds), or `null` if `timeData` is not provided.
|
|
8
8
|
*/
|
|
9
9
|
export default function timeDuration(timeData?: number, durationType?: string, now?: moment.Moment | null): number | null;
|
|
10
|
+
//# sourceMappingURL=timeDuration.d.mts.map
|
|
@@ -7,3 +7,4 @@
|
|
|
7
7
|
* @returns {Promise<Record<string, any>>} A promise that resolves with the session object once the session is processed.
|
|
8
8
|
*/
|
|
9
9
|
export default function cookieSession(socket: Record<string, any>, sessionModule: Function): Promise<Record<string, any>>;
|
|
10
|
+
//# sourceMappingURL=cookie-session.d.mts.map
|
|
@@ -8,3 +8,4 @@
|
|
|
8
8
|
* @returns {Promise<Record<string, any>>} A promise that resolves with the user data and updates the cache.
|
|
9
9
|
*/
|
|
10
10
|
export default function discord(socket: Record<string, any>, ioCache: Record<string, any>, token: string): Promise<Record<string, any>>;
|
|
11
|
+
//# sourceMappingURL=discord.d.mts.map
|
|
@@ -15,3 +15,4 @@ import { shuffleArray } from './array.mjs';
|
|
|
15
15
|
import { toTitleCase } from './text.mjs';
|
|
16
16
|
import { toTitleCaseLowerFirst } from './text.mjs';
|
|
17
17
|
export { extendObjType, reorderObjTypeOrder, cloneObjTypeOrder, countObj, objType, ruleOfThree, getSimplePerc, asyncReplace, getAge, formatCustomTimer, formatDayTimer, formatTimer, getTimeDuration, shuffleArray, toTitleCase, toTitleCaseLowerFirst };
|
|
18
|
+
//# sourceMappingURL=index.d.mts.map
|
|
@@ -23,64 +23,64 @@ var buffer = require('buffer');
|
|
|
23
23
|
*/
|
|
24
24
|
const typeValidator = {
|
|
25
25
|
items: {
|
|
26
|
-
/**
|
|
26
|
+
/** @param {*} val @returns {val is undefined} */
|
|
27
27
|
undefined: (val) => typeof val === 'undefined',
|
|
28
28
|
|
|
29
|
-
/**
|
|
29
|
+
/** @param {*} val @returns {val is null} */
|
|
30
30
|
null: (val) => val === null,
|
|
31
31
|
|
|
32
|
-
/**
|
|
32
|
+
/** @param {*} val @returns {val is boolean} */
|
|
33
33
|
boolean: (val) => typeof val === 'boolean',
|
|
34
34
|
|
|
35
|
-
/**
|
|
35
|
+
/** @param {*} val @returns {val is number} */
|
|
36
36
|
number: (val) => typeof val === 'number' && !isNaN(val),
|
|
37
37
|
|
|
38
|
-
/**
|
|
38
|
+
/** @param {*} val @returns {val is bigint} */
|
|
39
39
|
bigint: (val) => typeof val === 'bigint',
|
|
40
40
|
|
|
41
|
-
/**
|
|
41
|
+
/** @param {*} val @returns {val is string} */
|
|
42
42
|
string: (val) => typeof val === 'string',
|
|
43
43
|
|
|
44
|
-
/**
|
|
44
|
+
/** @param {*} val @returns {val is symbol} */
|
|
45
45
|
symbol: (val) => typeof val === 'symbol',
|
|
46
46
|
|
|
47
|
-
/**
|
|
47
|
+
/** @param {*} val @returns {val is Function} */
|
|
48
48
|
function: (val) => typeof val === 'function',
|
|
49
49
|
|
|
50
|
-
/**
|
|
50
|
+
/** @param {*} val @returns {val is Array<any>} */
|
|
51
51
|
array: (val) => Array.isArray(val),
|
|
52
52
|
|
|
53
|
-
/**
|
|
53
|
+
/** @param {*} val @returns {val is Date} */
|
|
54
54
|
date: (val) => val instanceof Date,
|
|
55
55
|
|
|
56
|
-
/**
|
|
56
|
+
/** @param {*} val @returns {val is RegExp} */
|
|
57
57
|
regexp: (val) => val instanceof RegExp,
|
|
58
58
|
|
|
59
|
-
/**
|
|
59
|
+
/** @param {*} val @returns {val is Map<any, any>} */
|
|
60
60
|
map: (val) => val instanceof Map,
|
|
61
61
|
|
|
62
|
-
/**
|
|
62
|
+
/** @param {*} val @returns {val is Set<any>} */
|
|
63
63
|
set: (val) => val instanceof Set,
|
|
64
64
|
|
|
65
|
-
/**
|
|
65
|
+
/** @param {*} val @returns {val is WeakMap<object, any>} */
|
|
66
66
|
weakmap: (val) => val instanceof WeakMap,
|
|
67
67
|
|
|
68
|
-
/**
|
|
68
|
+
/** @param {*} val @returns {val is WeakSet<object>} */
|
|
69
69
|
weakset: (val) => val instanceof WeakSet,
|
|
70
70
|
|
|
71
|
-
/**
|
|
71
|
+
/** @param {*} val @returns {val is Promise<any>} */
|
|
72
72
|
promise: (val) => val instanceof Promise,
|
|
73
73
|
|
|
74
|
-
/**
|
|
74
|
+
/** @param {*} val @returns {val is Buffer} */
|
|
75
75
|
buffer: (val) => typeof buffer.Buffer !== 'undefined' && buffer.Buffer.isBuffer(val),
|
|
76
76
|
|
|
77
|
-
/**
|
|
77
|
+
/** @param {*} val @returns {val is File} */
|
|
78
78
|
file: (val) => typeof File !== 'undefined' && val instanceof File,
|
|
79
79
|
|
|
80
|
-
/**
|
|
80
|
+
/** @param {*} val @returns {val is HTMLElement} */
|
|
81
81
|
htmlelement: (val) => typeof HTMLElement !== 'undefined' && val instanceof HTMLElement,
|
|
82
82
|
|
|
83
|
-
/**
|
|
83
|
+
/** @param {*} val @returns {val is object} */
|
|
84
84
|
object: (val) => typeof val === 'object' && val !== null,
|
|
85
85
|
},
|
|
86
86
|
|
|
@@ -207,7 +207,8 @@ function cloneObjTypeOrder() {
|
|
|
207
207
|
const getType = (val) => {
|
|
208
208
|
if (val === null) return 'null';
|
|
209
209
|
for (const name of typeValidator.order)
|
|
210
|
-
if (
|
|
210
|
+
if (typeof typeValidator.items[name] !== 'function' || typeValidator.items[name](val))
|
|
211
|
+
return name;
|
|
211
212
|
return 'unknown';
|
|
212
213
|
};
|
|
213
214
|
|
|
@@ -232,10 +233,32 @@ function objType(obj, type) {
|
|
|
232
233
|
return result;
|
|
233
234
|
}
|
|
234
235
|
|
|
236
|
+
/**
|
|
237
|
+
* Checks the type of a given object and returns the validation value if a known type is detected.
|
|
238
|
+
*
|
|
239
|
+
* @param {*} obj - The object to check or identify.
|
|
240
|
+
* @returns {{ valid:*; type: string | null }} - Returns the type result.
|
|
241
|
+
*/
|
|
242
|
+
function checkObj(obj) {
|
|
243
|
+
/** @type {{ valid:*; type: string | null }} */
|
|
244
|
+
const data = { valid: null, type: null };
|
|
245
|
+
for (const name of typeValidator.order) {
|
|
246
|
+
if (typeof typeValidator.items[name] === 'function') {
|
|
247
|
+
const result = typeValidator.items[name](obj);
|
|
248
|
+
if (result) {
|
|
249
|
+
data.valid = result;
|
|
250
|
+
data.type = name;
|
|
251
|
+
break;
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
return data;
|
|
256
|
+
}
|
|
257
|
+
|
|
235
258
|
/**
|
|
236
259
|
* Counts the number of elements in an array or the number of properties in an object.
|
|
237
260
|
*
|
|
238
|
-
* @param {
|
|
261
|
+
* @param {Array<*>|Record<string|number, any>} obj - The array or object to count.
|
|
239
262
|
* @returns {number} - The count of items (array elements or object keys), or `0` if the input is neither an array nor an object.
|
|
240
263
|
*
|
|
241
264
|
* @example
|
|
@@ -252,6 +275,7 @@ function countObj(obj) {
|
|
|
252
275
|
return 0;
|
|
253
276
|
}
|
|
254
277
|
|
|
278
|
+
exports.checkObj = checkObj;
|
|
255
279
|
exports.cloneObjTypeOrder = cloneObjTypeOrder;
|
|
256
280
|
exports.countObj = countObj;
|
|
257
281
|
exports.extendObjType = extendObjType;
|
|
@@ -52,10 +52,20 @@ export function cloneObjTypeOrder(): string[];
|
|
|
52
52
|
* objType(undefined); // null
|
|
53
53
|
*/
|
|
54
54
|
export function objType(obj: any, type?: string): boolean | string | null;
|
|
55
|
+
/**
|
|
56
|
+
* Checks the type of a given object and returns the validation value if a known type is detected.
|
|
57
|
+
*
|
|
58
|
+
* @param {*} obj - The object to check or identify.
|
|
59
|
+
* @returns {{ valid:*; type: string | null }} - Returns the type result.
|
|
60
|
+
*/
|
|
61
|
+
export function checkObj(obj: any): {
|
|
62
|
+
valid: any;
|
|
63
|
+
type: string | null;
|
|
64
|
+
};
|
|
55
65
|
/**
|
|
56
66
|
* Counts the number of elements in an array or the number of properties in an object.
|
|
57
67
|
*
|
|
58
|
-
* @param {
|
|
68
|
+
* @param {Array<*>|Record<string|number, any>} obj - The array or object to count.
|
|
59
69
|
* @returns {number} - The count of items (array elements or object keys), or `0` if the input is neither an array nor an object.
|
|
60
70
|
*
|
|
61
71
|
* @example
|
|
@@ -63,7 +73,7 @@ export function objType(obj: any, type?: string): boolean | string | null;
|
|
|
63
73
|
* countObj({ a: 1, b: 2 }); // 2
|
|
64
74
|
* countObj('not an object'); // 0
|
|
65
75
|
*/
|
|
66
|
-
export function countObj(obj: any): number;
|
|
76
|
+
export function countObj(obj: Array<any> | Record<string | number, any>): number;
|
|
67
77
|
/**
|
|
68
78
|
* An object containing type validation functions and their evaluation order.
|
|
69
79
|
*
|
|
@@ -85,3 +95,4 @@ export type TypeValidator = {
|
|
|
85
95
|
*/
|
|
86
96
|
order: string[];
|
|
87
97
|
};
|
|
98
|
+
//# sourceMappingURL=objFilter.d.mts.map
|