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.
Files changed (121) hide show
  1. package/dist/TinyBasicsEs.js +45 -22
  2. package/dist/TinyBasicsEs.min.js +1 -1
  3. package/dist/TinyEssentials.js +223 -22
  4. package/dist/TinyEssentials.min.js +1 -1
  5. package/dist/TinyPromiseQueue.js +214 -0
  6. package/dist/TinyPromiseQueue.min.js +1 -0
  7. package/dist/legacy/crypto/decrypt.d.mts +1 -0
  8. package/dist/legacy/crypto/default.d.mts +1 -0
  9. package/dist/legacy/crypto/encrypt.d.mts +1 -0
  10. package/dist/legacy/crypto/index.d.mts +1 -0
  11. package/dist/legacy/firebase/cookieSession.d.mts +1 -0
  12. package/dist/legacy/firebase/database/index.d.mts +1 -0
  13. package/dist/legacy/firebase/database/presence.d.mts +1 -0
  14. package/dist/legacy/firebase/database/saveAsync.d.mts +1 -0
  15. package/dist/legacy/firebase/databaseEscape.d.mts +1 -0
  16. package/dist/legacy/firebase/databaseLogger.d.mts +1 -0
  17. package/dist/legacy/firebase/discord/api/addGuildMember.d.mts +1 -0
  18. package/dist/legacy/firebase/discord/api/getGuildWidget.d.mts +1 -0
  19. package/dist/legacy/firebase/discord/api/getToken.d.mts +1 -0
  20. package/dist/legacy/firebase/discord/api/getUser.d.mts +1 -0
  21. package/dist/legacy/firebase/discord/api/getUserConnections.d.mts +1 -0
  22. package/dist/legacy/firebase/discord/api/getUserGuilds.d.mts +1 -0
  23. package/dist/legacy/firebase/discord/api/index.d.mts +1 -0
  24. package/dist/legacy/firebase/discord/api/refreshToken.d.mts +1 -0
  25. package/dist/legacy/firebase/discord/api/revokeToken.d.mts +1 -0
  26. package/dist/legacy/firebase/discord/config.d.mts +1 -0
  27. package/dist/legacy/firebase/discord/firebase_redirect/index.d.mts +1 -0
  28. package/dist/legacy/firebase/discord/firebase_redirect/login.d.mts +1 -0
  29. package/dist/legacy/firebase/discord/firebase_redirect/logout.d.mts +1 -0
  30. package/dist/legacy/firebase/discord/get/authURLGenerator.d.mts +1 -0
  31. package/dist/legacy/firebase/discord/get/cookie-session.d.mts +1 -0
  32. package/dist/legacy/firebase/discord/get/credentials.d.mts +1 -0
  33. package/dist/legacy/firebase/discord/get/errorValidator.d.mts +1 -0
  34. package/dist/legacy/firebase/discord/get/index.d.mts +1 -0
  35. package/dist/legacy/firebase/discord/get/randomAvatar.d.mts +1 -0
  36. package/dist/legacy/firebase/discord/http/index.d.mts +1 -0
  37. package/dist/legacy/firebase/discord/http/login.d.mts +1 -0
  38. package/dist/legacy/firebase/discord/http/logout.d.mts +1 -0
  39. package/dist/legacy/firebase/discord/http/redirect.d.mts +1 -0
  40. package/dist/legacy/firebase/discord/http/refreshToken.d.mts +1 -0
  41. package/dist/legacy/firebase/discord/index.d.mts +1 -0
  42. package/dist/legacy/firebase/discord/template/cookie-session.d.mts +1 -0
  43. package/dist/legacy/firebase/domainRedirect.d.mts +1 -0
  44. package/dist/legacy/firebase/escape.d.mts +1 -0
  45. package/dist/legacy/firebase/getDBAsync.d.mts +1 -0
  46. package/dist/legacy/firebase/getDBData.d.mts +1 -0
  47. package/dist/legacy/firebase/getDBValue.d.mts +1 -0
  48. package/dist/legacy/firebase/index.d.mts +1 -0
  49. package/dist/legacy/firebase/isEmulator.d.mts +1 -0
  50. package/dist/legacy/firebase/logger.d.mts +1 -0
  51. package/dist/legacy/firebase/mySQL.d.mts +1 -0
  52. package/dist/legacy/firebase/mysqlConnector/create.d.mts +1 -0
  53. package/dist/legacy/firebase/mysqlConnector/index.d.mts +1 -0
  54. package/dist/legacy/firebase/mysqlConnector/nextPrev.d.mts +1 -0
  55. package/dist/legacy/firebase/mysqlConnector/pagination.d.mts +1 -0
  56. package/dist/legacy/firebase/mysqlConnector/sameUser.d.mts +1 -0
  57. package/dist/legacy/firebase/transactionDBAsync.d.mts +1 -0
  58. package/dist/legacy/get/countObj.d.mts +1 -0
  59. package/dist/legacy/get/decimalColor.d.mts +1 -0
  60. package/dist/legacy/get/objType.d.mts +1 -0
  61. package/dist/legacy/get/pagination.d.mts +1 -0
  62. package/dist/legacy/get/queryUrlByName.d.mts +1 -0
  63. package/dist/legacy/get/queryUrlJSON.d.mts +1 -0
  64. package/dist/legacy/get/super_string_filter.d.mts +1 -0
  65. package/dist/legacy/get/versionCheck.d.mts +1 -0
  66. package/dist/legacy/http/HTTP-1.0.d.mts +1 -0
  67. package/dist/legacy/http/auth.d.mts +1 -0
  68. package/dist/legacy/http/check_domain.d.mts +1 -0
  69. package/dist/legacy/http/csrfTokenAnalyze.d.mts +1 -0
  70. package/dist/legacy/http/domainValidator.d.mts +1 -0
  71. package/dist/legacy/http/errorsCallback.d.mts +1 -0
  72. package/dist/legacy/http/fetch/json.d.mts +1 -0
  73. package/dist/legacy/http/fetch/text.d.mts +1 -0
  74. package/dist/legacy/http/fileCache.d.mts +1 -0
  75. package/dist/legacy/http/getDomainURL.d.mts +1 -0
  76. package/dist/legacy/http/userIP.d.mts +1 -0
  77. package/dist/legacy/index.d.mts +1 -0
  78. package/dist/legacy/libs/arraySortPositions.d.mts +1 -0
  79. package/dist/legacy/libs/capitalize.d.mts +1 -0
  80. package/dist/legacy/libs/convertBytes.d.mts +1 -0
  81. package/dist/legacy/libs/custom_module_loader.d.mts +1 -0
  82. package/dist/legacy/libs/dice.d.mts +1 -0
  83. package/dist/legacy/libs/markdown.d.mts +1 -0
  84. package/dist/legacy/libs/percentage.d.mts +1 -0
  85. package/dist/legacy/libs/regex/getLetter.d.mts +1 -0
  86. package/dist/legacy/libs/replaceAsync.d.mts +1 -0
  87. package/dist/legacy/libs/rule3.d.mts +1 -0
  88. package/dist/legacy/libs/userLevel.d.mts +1 -0
  89. package/dist/legacy/momentjs/getAge.d.mts +1 -0
  90. package/dist/legacy/momentjs/index.d.mts +1 -0
  91. package/dist/legacy/momentjs/timeDuration.d.mts +1 -0
  92. package/dist/legacy/socket.io/antiFlood/index.d.mts +1 -0
  93. package/dist/legacy/socket.io/antiFlood/install.d.mts +1 -0
  94. package/dist/legacy/socket.io/antiFlood/verify.d.mts +1 -0
  95. package/dist/legacy/socket.io/cookie-session.d.mts +1 -0
  96. package/dist/legacy/socket.io/discord.d.mts +1 -0
  97. package/dist/legacy/socket.io/index.d.mts +1 -0
  98. package/dist/v1/basics/array.d.mts +1 -0
  99. package/dist/v1/basics/clock.d.mts +1 -0
  100. package/dist/v1/basics/index.d.mts +1 -0
  101. package/dist/v1/basics/objFilter.cjs +46 -22
  102. package/dist/v1/basics/objFilter.d.mts +13 -2
  103. package/dist/v1/basics/objFilter.mjs +43 -22
  104. package/dist/v1/basics/simpleMath.d.mts +1 -0
  105. package/dist/v1/basics/text.d.mts +1 -0
  106. package/dist/v1/build/TinyLevelUp.d.mts +1 -0
  107. package/dist/v1/build/TinyPromiseQueue.cjs +7 -0
  108. package/dist/v1/build/TinyPromiseQueue.d.mts +3 -0
  109. package/dist/v1/build/TinyPromiseQueue.mjs +2 -0
  110. package/dist/v1/index.cjs +3 -0
  111. package/dist/v1/index.d.mts +4 -1
  112. package/dist/v1/index.mjs +3 -2
  113. package/dist/v1/libs/TinyPromiseQueue.cjs +175 -0
  114. package/dist/v1/libs/TinyPromiseQueue.d.mts +63 -0
  115. package/dist/v1/libs/TinyPromiseQueue.mjs +159 -0
  116. package/docs/README.md +5 -0
  117. package/docs/basics/asyncReplace.md +39 -0
  118. package/docs/basics/objFilter.md +33 -0
  119. package/docs/libs/TinyLevelUp.md +108 -0
  120. package/docs/libs/TinyPromiseQueue.md +126 -0
  121. 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
@@ -1 +1,2 @@
1
1
  export default function getDBData(data: any, type: any): Promise<any>;
2
+ //# sourceMappingURL=getDBData.d.mts.map
@@ -7,3 +7,4 @@
7
7
  * @returns {any} The value stored in the snapshot, or `null` if the data is invalid or doesn't contain a valid value.
8
8
  */
9
9
  export default function getDBValue(data: firebase.database.DataSnapshot): any;
10
+ //# sourceMappingURL=getDBValue.d.mts.map
@@ -49,3 +49,4 @@ import getDBData from './getDBData.mjs';
49
49
  import transactionDBAsync from './transactionDBAsync.mjs';
50
50
  import databaseEscape from './databaseEscape.mjs';
51
51
  import isEmulator from './isEmulator.mjs';
52
+ //# sourceMappingURL=index.d.mts.map
@@ -6,3 +6,4 @@
6
6
  * @returns {boolean} `true` if the Firebase Functions are running in the emulator, `false` otherwise.
7
7
  */
8
8
  export default function isEmulator(): boolean;
9
+ //# sourceMappingURL=isEmulator.d.mts.map
@@ -5,3 +5,4 @@ declare namespace fbLogger {
5
5
  function warn(...args: any[]): Promise<Record<string, any>>;
6
6
  function error(...args: any[]): Promise<Record<string, any>>;
7
7
  }
8
+ //# sourceMappingURL=logger.d.mts.map
@@ -8,3 +8,4 @@
8
8
  * @returns {Promise} Resolves with the connection object or rejects with an error.
9
9
  */
10
10
  export default function mySQL(mysql: Record<string, any>, databases: any[] | string, cfg: Record<string, any>): Promise<any>;
11
+ //# sourceMappingURL=mySQL.d.mts.map
@@ -34,3 +34,4 @@
34
34
  * ]);
35
35
  */
36
36
  export default function create(mysql: Record<string, any>, proxyType: string, databases: Record<string, any> | Record<string, any>[], cfg: Record<string, any>): Promise<Record<string, any>>;
37
+ //# sourceMappingURL=create.d.mts.map
@@ -9,3 +9,4 @@ import nextPrev from './nextPrev.mjs';
9
9
  import pagination from './pagination.mjs';
10
10
  import sameUser from './sameUser.mjs';
11
11
  import create from './create.mjs';
12
+ //# sourceMappingURL=index.d.mts.map
@@ -29,3 +29,4 @@ export default function nextPrev(db: Record<string, any>, tiny_search: {
29
29
  positionVar: string;
30
30
  };
31
31
  }): Promise<Object | null>;
32
+ //# sourceMappingURL=nextPrev.d.mts.map
@@ -31,3 +31,4 @@ export default function pagination(db: Record<string, any>, data: {
31
31
  count?: number | undefined;
32
32
  count_rows?: boolean | undefined;
33
33
  }): Promise<Record<string, any>>;
34
+ //# sourceMappingURL=pagination.d.mts.map
@@ -10,3 +10,4 @@
10
10
  export default function sameUser(database: string, login: {
11
11
  data: Object;
12
12
  }): Object | null;
13
+ //# sourceMappingURL=sameUser.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
@@ -9,3 +9,4 @@
9
9
  * @returns {number} The count of elements (array) or properties (object), or 0 if not applicable.
10
10
  */
11
11
  export default function countObj(obj: any): number;
12
+ //# sourceMappingURL=countObj.d.mts.map
@@ -10,3 +10,4 @@
10
10
  * @returns {number} The decimal representation of the color, or 0 if invalid.
11
11
  */
12
12
  export default function decimalColor(color: string | number, errCallback?: Function): number;
13
+ //# sourceMappingURL=decimalColor.d.mts.map
@@ -17,3 +17,4 @@
17
17
  * @returns {boolean|string|null} Returns true/false if checking, or type string/null if querying.
18
18
  */
19
19
  export default function objType(obj: any, type?: string): boolean | string | null;
20
+ //# sourceMappingURL=objType.d.mts.map
@@ -23,3 +23,4 @@
23
23
  * - `pages` {number} - Total number of pages.
24
24
  */
25
25
  export default function pagination(query: string, page: number, total: number, url?: string, extraClass?: string, extraClass2?: string): Record<string, any>;
26
+ //# sourceMappingURL=pagination.d.mts.map
@@ -18,3 +18,4 @@
18
18
  * @returns {string|null} The decoded value of the parameter, or `null` if not found.
19
19
  */
20
20
  export default function queryUrlByName(name: string, url: string): string | null;
21
+ //# sourceMappingURL=queryUrlByName.d.mts.map
@@ -21,3 +21,4 @@
21
21
  export default function queryUrlJSON(url?: string): {
22
22
  [x: string]: string | string[];
23
23
  };
24
+ //# sourceMappingURL=queryUrlJSON.d.mts.map
@@ -23,3 +23,4 @@
23
23
  * @returns {string[]} A filtered array of strings that passed at least one validator.
24
24
  */
25
25
  export default function super_string_filter(list: string[], validator_list: (string | Object)[]): string[];
26
+ //# sourceMappingURL=super_string_filter.d.mts.map
@@ -15,3 +15,4 @@ export default function versionCheck(pkg: {
15
15
  name: string;
16
16
  version: string;
17
17
  }): Promise<Record<string, any>>;
18
+ //# sourceMappingURL=versionCheck.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
@@ -39,3 +39,4 @@ export default function auth(data: {
39
39
  password: string;
40
40
  customError?: Function | undefined;
41
41
  }, callback?: Function): Function;
42
+ //# sourceMappingURL=auth.d.mts.map
@@ -8,3 +8,4 @@ declare namespace check_domain {
8
8
  function validator(req: Record<string, any>, the_domain: string): boolean;
9
9
  function get(req: Record<string, any>): string | null;
10
10
  }
11
+ //# sourceMappingURL=check_domain.d.mts.map
@@ -19,3 +19,4 @@
19
19
  * });
20
20
  */
21
21
  export default function csrfTokenAnalyze(req: Record<string, any>, res: Record<string, any>, callback?: Function): boolean;
22
+ //# sourceMappingURL=csrfTokenAnalyze.d.mts.map
@@ -28,3 +28,4 @@
28
28
  * }
29
29
  */
30
30
  export default function domainValidator(req: Record<string, any>, cfg: Record<string, any>): Record<string, any>;
31
+ //# sourceMappingURL=domainValidator.d.mts.map
@@ -27,3 +27,4 @@
27
27
  * }));
28
28
  */
29
29
  export default function errorsCallback(callback: Function): Function;
30
+ //# sourceMappingURL=errorsCallback.d.mts.map
@@ -20,3 +20,4 @@
20
20
  * .catch(err => console.error('Fetch error:', err));
21
21
  */
22
22
  export default function getJsonFetch(...args: any[]): Promise<any>;
23
+ //# sourceMappingURL=json.d.mts.map
@@ -19,3 +19,4 @@
19
19
  * .catch(err => console.error('Fetch error:', err));
20
20
  */
21
21
  export default function getTextFetch(...args: any[]): Promise<string>;
22
+ //# sourceMappingURL=text.d.mts.map
@@ -33,3 +33,4 @@ export default function fileCache(res: object, next: Function, data: {
33
33
  timezone?: string | undefined;
34
34
  contentType?: string | undefined;
35
35
  }): void;
36
+ //# sourceMappingURL=fileCache.d.mts.map
@@ -16,3 +16,4 @@
16
16
  * getDomainURL(req, 8080); // Uses domain from request object
17
17
  */
18
18
  export default function getDomainURL(domain: string | object, port?: number, httpResult?: string): string;
19
+ //# sourceMappingURL=getDomainURL.d.mts.map
@@ -17,3 +17,4 @@ export default function userIp(req: import("express").Request, options?: Record<
17
17
  value: string[] | null;
18
18
  type: string | null;
19
19
  };
20
+ //# sourceMappingURL=userIP.d.mts.map
@@ -87,3 +87,4 @@ import capitalize from './libs/capitalize.mjs';
87
87
  import getJsonFetch from './http/fetch/json.mjs';
88
88
  import getTextFetch from './http/fetch/text.mjs';
89
89
  import csrfTokenAnalyze from './http/csrfTokenAnalyze.mjs';
90
+ //# sourceMappingURL=index.d.mts.map
@@ -14,3 +14,4 @@
14
14
  * arr.sort(arraySortPositions('pos', true)); // Descending: [{pos: 3}, {pos: 2}, {pos: 1}]
15
15
  */
16
16
  export default function arraySortPositions(item: string, isReverse?: boolean): (a: Object, b: Object) => number;
17
+ //# sourceMappingURL=arraySortPositions.d.mts.map
@@ -11,3 +11,4 @@
11
11
  * capitalize("my little pony"); // "My Little Pony"
12
12
  */
13
13
  export default function capitalize(text: string): string;
14
+ //# sourceMappingURL=capitalize.d.mts.map
@@ -15,3 +15,4 @@ declare namespace convertList {
15
15
  let eb: number;
16
16
  }
17
17
  declare const sequence: string[];
18
+ //# sourceMappingURL=convertBytes.d.mts.map
@@ -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
@@ -3,3 +3,4 @@ declare namespace tinyDice {
3
3
  function vanilla(obj: number): number;
4
4
  function getClientVanilla(obj: number): string;
5
5
  }
6
+ //# sourceMappingURL=dice.d.mts.map
@@ -73,3 +73,4 @@ declare namespace markdownManager {
73
73
  }
74
74
  function parseMarkdown(markdownText: string, type?: "result" | "bbcode"): string;
75
75
  }
76
+ //# sourceMappingURL=markdown.d.mts.map
@@ -2,3 +2,4 @@ export default percentageBase;
2
2
  declare namespace percentageBase {
3
3
  function run(preco: number, porcentagem: number): number;
4
4
  }
5
+ //# sourceMappingURL=percentage.d.mts.map
@@ -10,3 +10,4 @@ export function oneLetter(type?: string): RegExp;
10
10
  * @returns {RegExp} The regular expression to match one or more letters.
11
11
  */
12
12
  export function multiLetters(type?: string): RegExp;
13
+ //# sourceMappingURL=getLetter.d.mts.map
@@ -13,3 +13,4 @@
13
13
  * });
14
14
  */
15
15
  export default function asyncReplace(str: string, regex: RegExp, asyncFn: Function): Promise<string>;
16
+ //# sourceMappingURL=replaceAsync.d.mts.map
@@ -3,3 +3,4 @@ declare namespace ruleOfThree {
3
3
  function getClient(): string;
4
4
  function execute(val1: number, val2: number, val3: number, inverse: boolean): number;
5
5
  }
6
+ //# sourceMappingURL=rule3.d.mts.map
@@ -112,3 +112,4 @@ declare class TinyLevelUp {
112
112
  totalExp: number;
113
113
  };
114
114
  }
115
+ //# sourceMappingURL=userLevel.d.mts.map
@@ -6,3 +6,4 @@
6
6
  * @returns {number|null} The age in years, or null if `timeData` is not provided.
7
7
  */
8
8
  export default function getAge(timeData?: number | string, now?: moment.Moment | null): number | null;
9
+ //# sourceMappingURL=getAge.d.mts.map
@@ -1,3 +1,4 @@
1
1
  import timeDuration from './timeDuration.mjs';
2
2
  import getAge from './getAge.mjs';
3
3
  export { timeDuration, getAge };
4
+ //# sourceMappingURL=index.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
@@ -1,3 +1,4 @@
1
1
  import verify from './verify.mjs';
2
2
  import install from './install.mjs';
3
3
  export { verify, install };
4
+ //# sourceMappingURL=index.d.mts.map
@@ -10,3 +10,4 @@
10
10
  * @returns {void} This function does not return a value, it just sets the authorization logic for socket connections.
11
11
  */
12
12
  export default function install(io: Record<string, any>, ioCache: Record<string, any>): void;
13
+ //# sourceMappingURL=install.d.mts.map
@@ -11,3 +11,4 @@
11
11
  * @returns {void} This function does not return anything, it modifies the floodPanel and blocklist.
12
12
  */
13
13
  export default function verify(socket: Record<string, any>, ioCache: Record<string, any>): void;
14
+ //# sourceMappingURL=verify.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
@@ -7,3 +7,4 @@ declare const socketIo: {
7
7
  import * as antiFlood from './antiFlood/index.mjs';
8
8
  import cookieSession from './cookie-session.mjs';
9
9
  import discord from './discord.mjs';
10
+ //# sourceMappingURL=index.d.mts.map
@@ -8,3 +8,4 @@
8
8
  * @returns {string[]} The same array instance, now shuffled in place.
9
9
  */
10
10
  export function shuffleArray(items: string[]): string[];
11
+ //# sourceMappingURL=array.d.mts.map
@@ -35,3 +35,4 @@ export function formatTimer(seconds: number): string;
35
35
  * @returns {string} The formatted timer string in "Xd HH:MM:SS" format.
36
36
  */
37
37
  export function formatDayTimer(seconds: number): string;
38
+ //# sourceMappingURL=clock.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
- /** Checks if the value is undefined. */
26
+ /** @param {*} val @returns {val is undefined} */
27
27
  undefined: (val) => typeof val === 'undefined',
28
28
 
29
- /** Checks if the value is null. */
29
+ /** @param {*} val @returns {val is null} */
30
30
  null: (val) => val === null,
31
31
 
32
- /** Checks if the value is a boolean. */
32
+ /** @param {*} val @returns {val is boolean} */
33
33
  boolean: (val) => typeof val === 'boolean',
34
34
 
35
- /** Checks if the value is a number. */
35
+ /** @param {*} val @returns {val is number} */
36
36
  number: (val) => typeof val === 'number' && !isNaN(val),
37
37
 
38
- /** Checks if the value is a bigint. */
38
+ /** @param {*} val @returns {val is bigint} */
39
39
  bigint: (val) => typeof val === 'bigint',
40
40
 
41
- /** Checks if the value is a string. */
41
+ /** @param {*} val @returns {val is string} */
42
42
  string: (val) => typeof val === 'string',
43
43
 
44
- /** Checks if the value is a symbol. */
44
+ /** @param {*} val @returns {val is symbol} */
45
45
  symbol: (val) => typeof val === 'symbol',
46
46
 
47
- /** Checks if the value is a function. */
47
+ /** @param {*} val @returns {val is Function} */
48
48
  function: (val) => typeof val === 'function',
49
49
 
50
- /** Checks if the value is an array. */
50
+ /** @param {*} val @returns {val is Array<any>} */
51
51
  array: (val) => Array.isArray(val),
52
52
 
53
- /** Checks if the value is a Date object. */
53
+ /** @param {*} val @returns {val is Date} */
54
54
  date: (val) => val instanceof Date,
55
55
 
56
- /** Checks if the value is a regular expression. */
56
+ /** @param {*} val @returns {val is RegExp} */
57
57
  regexp: (val) => val instanceof RegExp,
58
58
 
59
- /** Checks if the value is a Map. */
59
+ /** @param {*} val @returns {val is Map<any, any>} */
60
60
  map: (val) => val instanceof Map,
61
61
 
62
- /** Checks if the value is a Set. */
62
+ /** @param {*} val @returns {val is Set<any>} */
63
63
  set: (val) => val instanceof Set,
64
64
 
65
- /** Checks if the value is a WeakMap. */
65
+ /** @param {*} val @returns {val is WeakMap<object, any>} */
66
66
  weakmap: (val) => val instanceof WeakMap,
67
67
 
68
- /** Checks if the value is a WeakSet. */
68
+ /** @param {*} val @returns {val is WeakSet<object>} */
69
69
  weakset: (val) => val instanceof WeakSet,
70
70
 
71
- /** Checks if the value is a Promise. */
71
+ /** @param {*} val @returns {val is Promise<any>} */
72
72
  promise: (val) => val instanceof Promise,
73
73
 
74
- /** Checks if the value is a Buffer. */
74
+ /** @param {*} val @returns {val is Buffer} */
75
75
  buffer: (val) => typeof buffer.Buffer !== 'undefined' && buffer.Buffer.isBuffer(val),
76
76
 
77
- /** Checks if the value is a File. */
77
+ /** @param {*} val @returns {val is File} */
78
78
  file: (val) => typeof File !== 'undefined' && val instanceof File,
79
79
 
80
- /** Checks if the value is a Html Element. */
80
+ /** @param {*} val @returns {val is HTMLElement} */
81
81
  htmlelement: (val) => typeof HTMLElement !== 'undefined' && val instanceof HTMLElement,
82
82
 
83
- /** Checks if the value is a non-null plain object or instance of a class. */
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 (!typeValidator.items[name] || typeValidator.items[name](val)) return name;
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 {*} obj - The array or object to count.
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 {*} obj - The array or object to count.
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