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.
- package/.github/FUNDING.yml +4 -0
- package/.github/workflows/node.js.yml +31 -0
- package/LICENSE +674 -0
- package/README.md +67 -0
- package/dist/TinyEssentials.min.js +1 -0
- package/dist/_virtual/_commonjsHelpers.cjs +7 -0
- package/dist/_virtual/common.cjs +5 -0
- package/dist/_virtual/index.cjs +9 -0
- package/dist/_virtual/index2.cjs +5 -0
- package/dist/_virtual/trace.cjs +5 -0
- package/dist/legacy/crypto/decrypt.cjs +57 -0
- package/dist/legacy/crypto/decrypt.d.mts +18 -0
- package/dist/legacy/crypto/decrypt.mjs +47 -0
- package/dist/legacy/crypto/default.cjs +23 -0
- package/dist/legacy/crypto/default.d.mts +35 -0
- package/dist/legacy/crypto/default.mjs +19 -0
- package/dist/legacy/crypto/encrypt.cjs +54 -0
- package/dist/legacy/crypto/encrypt.d.mts +19 -0
- package/dist/legacy/crypto/encrypt.mjs +46 -0
- package/dist/legacy/crypto/index.cjs +11 -0
- package/dist/legacy/crypto/index.d.mts +4 -0
- package/dist/legacy/crypto/index.mjs +6 -0
- package/dist/legacy/firebase/cookieSession.cjs +121 -0
- package/dist/legacy/firebase/cookieSession.d.mts +56 -0
- package/dist/legacy/firebase/cookieSession.mjs +114 -0
- package/dist/legacy/firebase/database/index.cjs +11 -0
- package/dist/legacy/firebase/database/index.d.mts +7 -0
- package/dist/legacy/firebase/database/index.mjs +7 -0
- package/dist/legacy/firebase/database/presence.cjs +131 -0
- package/dist/legacy/firebase/database/presence.d.mts +9 -0
- package/dist/legacy/firebase/database/presence.mjs +111 -0
- package/dist/legacy/firebase/database/saveAsync.cjs +147 -0
- package/dist/legacy/firebase/database/saveAsync.d.mts +54 -0
- package/dist/legacy/firebase/database/saveAsync.mjs +147 -0
- package/dist/legacy/firebase/databaseEscape.cjs +42 -0
- package/dist/legacy/firebase/databaseEscape.d.mts +11 -0
- package/dist/legacy/firebase/databaseEscape.mjs +37 -0
- package/dist/legacy/firebase/databaseLogger.cjs +258 -0
- package/dist/legacy/firebase/databaseLogger.d.mts +7 -0
- package/dist/legacy/firebase/databaseLogger.mjs +234 -0
- package/dist/legacy/firebase/discord/api/addGuildMember.cjs +71 -0
- package/dist/legacy/firebase/discord/api/addGuildMember.d.mts +38 -0
- package/dist/legacy/firebase/discord/api/addGuildMember.mjs +64 -0
- package/dist/legacy/firebase/discord/api/getGuildWidget.cjs +47 -0
- package/dist/legacy/firebase/discord/api/getGuildWidget.d.mts +17 -0
- package/dist/legacy/firebase/discord/api/getGuildWidget.mjs +43 -0
- package/dist/legacy/firebase/discord/api/getToken.cjs +67 -0
- package/dist/legacy/firebase/discord/api/getToken.d.mts +35 -0
- package/dist/legacy/firebase/discord/api/getToken.mjs +63 -0
- package/dist/legacy/firebase/discord/api/getUser.cjs +58 -0
- package/dist/legacy/firebase/discord/api/getUser.d.mts +27 -0
- package/dist/legacy/firebase/discord/api/getUser.mjs +54 -0
- package/dist/legacy/firebase/discord/api/getUserConnections.cjs +57 -0
- package/dist/legacy/firebase/discord/api/getUserConnections.d.mts +26 -0
- package/dist/legacy/firebase/discord/api/getUserConnections.mjs +53 -0
- package/dist/legacy/firebase/discord/api/getUserGuilds.cjs +56 -0
- package/dist/legacy/firebase/discord/api/getUserGuilds.d.mts +25 -0
- package/dist/legacy/firebase/discord/api/getUserGuilds.mjs +52 -0
- package/dist/legacy/firebase/discord/api/index.cjs +24 -0
- package/dist/legacy/firebase/discord/api/index.d.mts +19 -0
- package/dist/legacy/firebase/discord/api/index.mjs +20 -0
- package/dist/legacy/firebase/discord/api/refreshToken.cjs +77 -0
- package/dist/legacy/firebase/discord/api/refreshToken.d.mts +45 -0
- package/dist/legacy/firebase/discord/api/refreshToken.mjs +73 -0
- package/dist/legacy/firebase/discord/api/revokeToken.cjs +61 -0
- package/dist/legacy/firebase/discord/api/revokeToken.d.mts +29 -0
- package/dist/legacy/firebase/discord/api/revokeToken.mjs +58 -0
- package/dist/legacy/firebase/discord/config.cjs +21 -0
- package/dist/legacy/firebase/discord/config.d.mts +27 -0
- package/dist/legacy/firebase/discord/config.mjs +17 -0
- package/dist/legacy/firebase/discord/firebase_redirect/index.cjs +11 -0
- package/dist/legacy/firebase/discord/firebase_redirect/index.d.mts +7 -0
- package/dist/legacy/firebase/discord/firebase_redirect/index.mjs +7 -0
- package/dist/legacy/firebase/discord/firebase_redirect/login.cjs +110 -0
- package/dist/legacy/firebase/discord/firebase_redirect/login.d.mts +4 -0
- package/dist/legacy/firebase/discord/firebase_redirect/login.mjs +107 -0
- package/dist/legacy/firebase/discord/firebase_redirect/logout.cjs +100 -0
- package/dist/legacy/firebase/discord/firebase_redirect/logout.d.mts +4 -0
- package/dist/legacy/firebase/discord/firebase_redirect/logout.mjs +97 -0
- package/dist/legacy/firebase/discord/get/authURLGenerator.cjs +76 -0
- package/dist/legacy/firebase/discord/get/authURLGenerator.d.mts +23 -0
- package/dist/legacy/firebase/discord/get/authURLGenerator.mjs +67 -0
- package/dist/legacy/firebase/discord/get/cookie-session.cjs +32 -0
- package/dist/legacy/firebase/discord/get/cookie-session.d.mts +20 -0
- package/dist/legacy/firebase/discord/get/cookie-session.mjs +28 -0
- package/dist/legacy/firebase/discord/get/credentials.cjs +24 -0
- package/dist/legacy/firebase/discord/get/credentials.d.mts +19 -0
- package/dist/legacy/firebase/discord/get/credentials.mjs +20 -0
- package/dist/legacy/firebase/discord/get/errorValidator.cjs +60 -0
- package/dist/legacy/firebase/discord/get/errorValidator.d.mts +28 -0
- package/dist/legacy/firebase/discord/get/errorValidator.mjs +55 -0
- package/dist/legacy/firebase/discord/get/index.cjs +17 -0
- package/dist/legacy/firebase/discord/get/index.d.mts +13 -0
- package/dist/legacy/firebase/discord/get/index.mjs +13 -0
- package/dist/legacy/firebase/discord/get/randomAvatar.cjs +37 -0
- package/dist/legacy/firebase/discord/get/randomAvatar.d.mts +22 -0
- package/dist/legacy/firebase/discord/get/randomAvatar.mjs +30 -0
- package/dist/legacy/firebase/discord/http/index.cjs +15 -0
- package/dist/legacy/firebase/discord/http/index.d.mts +11 -0
- package/dist/legacy/firebase/discord/http/index.mjs +11 -0
- package/dist/legacy/firebase/discord/http/login.cjs +127 -0
- package/dist/legacy/firebase/discord/http/login.d.mts +21 -0
- package/dist/legacy/firebase/discord/http/login.mjs +123 -0
- package/dist/legacy/firebase/discord/http/logout.cjs +155 -0
- package/dist/legacy/firebase/discord/http/logout.d.mts +22 -0
- package/dist/legacy/firebase/discord/http/logout.mjs +143 -0
- package/dist/legacy/firebase/discord/http/redirect.cjs +188 -0
- package/dist/legacy/firebase/discord/http/redirect.d.mts +24 -0
- package/dist/legacy/firebase/discord/http/redirect.mjs +178 -0
- package/dist/legacy/firebase/discord/http/refreshToken.cjs +133 -0
- package/dist/legacy/firebase/discord/http/refreshToken.d.mts +24 -0
- package/dist/legacy/firebase/discord/http/refreshToken.mjs +121 -0
- package/dist/legacy/firebase/discord/index.cjs +19 -0
- package/dist/legacy/firebase/discord/index.d.mts +15 -0
- package/dist/legacy/firebase/discord/index.mjs +15 -0
- package/dist/legacy/firebase/discord/template/cookie-session.cjs +1430 -0
- package/dist/legacy/firebase/discord/template/cookie-session.d.mts +22 -0
- package/dist/legacy/firebase/discord/template/cookie-session.mjs +1159 -0
- package/dist/legacy/firebase/domainRedirect.cjs +35 -0
- package/dist/legacy/firebase/domainRedirect.d.mts +12 -0
- package/dist/legacy/firebase/domainRedirect.mjs +27 -0
- package/dist/legacy/firebase/escape.cjs +75 -0
- package/dist/legacy/firebase/escape.d.mts +17 -0
- package/dist/legacy/firebase/escape.mjs +58 -0
- package/dist/legacy/firebase/getDBAsync.cjs +33 -0
- package/dist/legacy/firebase/getDBAsync.d.mts +10 -0
- package/dist/legacy/firebase/getDBAsync.mjs +26 -0
- package/dist/legacy/firebase/getDBData.cjs +21 -0
- package/dist/legacy/firebase/getDBData.d.mts +1 -0
- package/dist/legacy/firebase/getDBData.mjs +17 -0
- package/dist/legacy/firebase/getDBValue.cjs +17 -0
- package/dist/legacy/firebase/getDBValue.d.mts +9 -0
- package/dist/legacy/firebase/getDBValue.mjs +14 -0
- package/dist/legacy/firebase/index.cjs +261 -0
- package/dist/legacy/firebase/index.d.mts +51 -0
- package/dist/legacy/firebase/index.mjs +234 -0
- package/dist/legacy/firebase/isEmulator.cjs +14 -0
- package/dist/legacy/firebase/isEmulator.d.mts +8 -0
- package/dist/legacy/firebase/isEmulator.mjs +10 -0
- package/dist/legacy/firebase/logger.cjs +137 -0
- package/dist/legacy/firebase/logger.d.mts +7 -0
- package/dist/legacy/firebase/logger.mjs +125 -0
- package/dist/legacy/firebase/mySQL.cjs +26 -0
- package/dist/legacy/firebase/mySQL.d.mts +10 -0
- package/dist/legacy/firebase/mySQL.mjs +22 -0
- package/dist/legacy/firebase/mysqlConnector/create.cjs +119 -0
- package/dist/legacy/firebase/mysqlConnector/create.d.mts +36 -0
- package/dist/legacy/firebase/mysqlConnector/create.mjs +109 -0
- package/dist/legacy/firebase/mysqlConnector/index.cjs +23 -0
- package/dist/legacy/firebase/mysqlConnector/index.d.mts +11 -0
- package/dist/legacy/firebase/mysqlConnector/index.mjs +16 -0
- package/dist/legacy/firebase/mysqlConnector/nextPrev.cjs +75 -0
- package/dist/legacy/firebase/mysqlConnector/nextPrev.d.mts +31 -0
- package/dist/legacy/firebase/mysqlConnector/nextPrev.mjs +63 -0
- package/dist/legacy/firebase/mysqlConnector/pagination.cjs +91 -0
- package/dist/legacy/firebase/mysqlConnector/pagination.d.mts +33 -0
- package/dist/legacy/firebase/mysqlConnector/pagination.mjs +87 -0
- package/dist/legacy/firebase/mysqlConnector/sameUser.cjs +28 -0
- package/dist/legacy/firebase/mysqlConnector/sameUser.d.mts +12 -0
- package/dist/legacy/firebase/mysqlConnector/sameUser.mjs +23 -0
- package/dist/legacy/firebase/transactionDBAsync.cjs +33 -0
- package/dist/legacy/firebase/transactionDBAsync.d.mts +11 -0
- package/dist/legacy/firebase/transactionDBAsync.mjs +27 -0
- package/dist/legacy/get/countObj.cjs +24 -0
- package/dist/legacy/get/countObj.d.mts +11 -0
- package/dist/legacy/get/countObj.mjs +21 -0
- package/dist/legacy/get/decimalColor.cjs +60 -0
- package/dist/legacy/get/decimalColor.d.mts +12 -0
- package/dist/legacy/get/decimalColor.mjs +54 -0
- package/dist/legacy/get/objType.cjs +43 -0
- package/dist/legacy/get/objType.d.mts +19 -0
- package/dist/legacy/get/objType.mjs +40 -0
- package/dist/legacy/get/pagination.cjs +100 -0
- package/dist/legacy/get/pagination.d.mts +25 -0
- package/dist/legacy/get/pagination.mjs +91 -0
- package/dist/legacy/get/queryUrlByName.cjs +31 -0
- package/dist/legacy/get/queryUrlByName.d.mts +20 -0
- package/dist/legacy/get/queryUrlByName.mjs +28 -0
- package/dist/legacy/get/queryUrlJSON.cjs +54 -0
- package/dist/legacy/get/queryUrlJSON.d.mts +23 -0
- package/dist/legacy/get/queryUrlJSON.mjs +57 -0
- package/dist/legacy/get/super_string_filter.cjs +97 -0
- package/dist/legacy/get/super_string_filter.d.mts +25 -0
- package/dist/legacy/get/super_string_filter.mjs +83 -0
- package/dist/legacy/get/versionCheck.cjs +49 -0
- package/dist/legacy/get/versionCheck.d.mts +17 -0
- package/dist/legacy/get/versionCheck.mjs +38 -0
- package/dist/legacy/http/HTTP-1.0.cjs +151 -0
- package/dist/legacy/http/HTTP-1.0.d.mts +8 -0
- package/dist/legacy/http/HTTP-1.0.mjs +136 -0
- package/dist/legacy/http/auth.cjs +70 -0
- package/dist/legacy/http/auth.d.mts +41 -0
- package/dist/legacy/http/auth.mjs +63 -0
- package/dist/legacy/http/check_domain.cjs +84 -0
- package/dist/legacy/http/check_domain.d.mts +10 -0
- package/dist/legacy/http/check_domain.mjs +82 -0
- package/dist/legacy/http/csrfTokenAnalyze.cjs +46 -0
- package/dist/legacy/http/csrfTokenAnalyze.d.mts +21 -0
- package/dist/legacy/http/csrfTokenAnalyze.mjs +40 -0
- package/dist/legacy/http/domainValidator.cjs +98 -0
- package/dist/legacy/http/domainValidator.d.mts +30 -0
- package/dist/legacy/http/domainValidator.mjs +82 -0
- package/dist/legacy/http/errorsCallback.cjs +55 -0
- package/dist/legacy/http/errorsCallback.d.mts +29 -0
- package/dist/legacy/http/errorsCallback.mjs +48 -0
- package/dist/legacy/http/fetch/json.cjs +48 -0
- package/dist/legacy/http/fetch/json.d.mts +22 -0
- package/dist/legacy/http/fetch/json.mjs +41 -0
- package/dist/legacy/http/fetch/text.cjs +47 -0
- package/dist/legacy/http/fetch/text.d.mts +21 -0
- package/dist/legacy/http/fetch/text.mjs +40 -0
- package/dist/legacy/http/fileCache.cjs +79 -0
- package/dist/legacy/http/fileCache.d.mts +35 -0
- package/dist/legacy/http/fileCache.mjs +70 -0
- package/dist/legacy/http/getDomainURL.cjs +59 -0
- package/dist/legacy/http/getDomainURL.d.mts +18 -0
- package/dist/legacy/http/getDomainURL.mjs +54 -0
- package/dist/legacy/http/userIP.cjs +59 -0
- package/dist/legacy/http/userIP.d.mts +21 -0
- package/dist/legacy/http/userIP.mjs +48 -0
- package/dist/legacy/index.cjs +122 -0
- package/dist/legacy/index.d.mts +89 -0
- package/dist/legacy/index.mjs +92 -0
- package/dist/legacy/libs/arraySortPositions.cjs +30 -0
- package/dist/legacy/libs/arraySortPositions.d.mts +16 -0
- package/dist/legacy/libs/arraySortPositions.mjs +27 -0
- package/dist/legacy/libs/capitalize.cjs +21 -0
- package/dist/legacy/libs/capitalize.d.mts +13 -0
- package/dist/legacy/libs/capitalize.mjs +17 -0
- package/dist/legacy/libs/convertBytes.cjs +64 -0
- package/dist/legacy/libs/convertBytes.d.mts +17 -0
- package/dist/legacy/libs/convertBytes.mjs +55 -0
- package/dist/legacy/libs/custom_module_loader.cjs +82 -0
- package/dist/legacy/libs/custom_module_loader.d.mts +5 -0
- package/dist/legacy/libs/custom_module_loader.mjs +79 -0
- package/dist/legacy/libs/dice.cjs +35 -0
- package/dist/legacy/libs/dice.d.mts +5 -0
- package/dist/legacy/libs/dice.mjs +31 -0
- package/dist/legacy/libs/markdown.cjs +85 -0
- package/dist/legacy/libs/markdown.d.mts +75 -0
- package/dist/legacy/libs/markdown.mjs +78 -0
- package/dist/legacy/libs/percentage.cjs +22 -0
- package/dist/legacy/libs/percentage.d.mts +4 -0
- package/dist/legacy/libs/percentage.mjs +19 -0
- package/dist/legacy/libs/regex/getLetter.cjs +22 -0
- package/dist/legacy/libs/regex/getLetter.d.mts +12 -0
- package/dist/legacy/libs/regex/getLetter.mjs +19 -0
- package/dist/legacy/libs/replaceAsync.cjs +32 -0
- package/dist/legacy/libs/replaceAsync.d.mts +15 -0
- package/dist/legacy/libs/replaceAsync.mjs +25 -0
- package/dist/legacy/libs/rule3.cjs +58 -0
- package/dist/legacy/libs/rule3.d.mts +5 -0
- package/dist/legacy/libs/rule3.mjs +54 -0
- package/dist/legacy/libs/userLevel.cjs +134 -0
- package/dist/legacy/libs/userLevel.d.mts +69 -0
- package/dist/legacy/libs/userLevel.mjs +123 -0
- package/dist/legacy/momentjs/getAge.cjs +28 -0
- package/dist/legacy/momentjs/getAge.d.mts +8 -0
- package/dist/legacy/momentjs/getAge.mjs +22 -0
- package/dist/legacy/momentjs/index.cjs +9 -0
- package/dist/legacy/momentjs/index.d.mts +3 -0
- package/dist/legacy/momentjs/index.mjs +3 -0
- package/dist/legacy/momentjs/timeDuration.cjs +29 -0
- package/dist/legacy/momentjs/timeDuration.d.mts +9 -0
- package/dist/legacy/momentjs/timeDuration.mjs +23 -0
- package/dist/legacy/socket.io/antiFlood/index.cjs +9 -0
- package/dist/legacy/socket.io/antiFlood/index.d.mts +3 -0
- package/dist/legacy/socket.io/antiFlood/index.mjs +3 -0
- package/dist/legacy/socket.io/antiFlood/install.cjs +32 -0
- package/dist/legacy/socket.io/antiFlood/install.d.mts +14 -0
- package/dist/legacy/socket.io/antiFlood/install.mjs +27 -0
- package/dist/legacy/socket.io/antiFlood/verify.cjs +87 -0
- package/dist/legacy/socket.io/antiFlood/verify.d.mts +15 -0
- package/dist/legacy/socket.io/antiFlood/verify.mjs +73 -0
- package/dist/legacy/socket.io/cookie-session.cjs +25 -0
- package/dist/legacy/socket.io/cookie-session.d.mts +9 -0
- package/dist/legacy/socket.io/cookie-session.mjs +20 -0
- package/dist/legacy/socket.io/discord.cjs +61 -0
- package/dist/legacy/socket.io/discord.d.mts +10 -0
- package/dist/legacy/socket.io/discord.mjs +52 -0
- package/dist/legacy/socket.io/index.cjs +13 -0
- package/dist/legacy/socket.io/index.d.mts +9 -0
- package/dist/legacy/socket.io/index.mjs +9 -0
- package/dist/v1/basics/array.cjs +31 -0
- package/dist/v1/basics/array.d.mts +10 -0
- package/dist/v1/basics/array.mjs +22 -0
- package/dist/v1/basics/clock.cjs +187 -0
- package/dist/v1/basics/clock.d.mts +37 -0
- package/dist/v1/basics/clock.mjs +152 -0
- package/dist/v1/basics/objFilter.cjs +55 -0
- package/dist/v1/basics/objFilter.d.mts +27 -0
- package/dist/v1/basics/objFilter.mjs +52 -0
- package/dist/v1/basics/simpleMath.cjs +88 -0
- package/dist/v1/basics/simpleMath.d.mts +54 -0
- package/dist/v1/basics/simpleMath.mjs +75 -0
- package/dist/v1/basics/text.cjs +34 -0
- package/dist/v1/basics/text.d.mts +20 -0
- package/dist/v1/basics/text.mjs +25 -0
- package/dist/v1/index.cjs +26 -0
- package/dist/v1/index.d.mts +15 -0
- package/dist/v1/index.mjs +8 -0
- package/package.json +72 -0
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import queryUrlJSON from './queryUrlJSON.mjs';
|
|
2
|
+
/**
|
|
3
|
+
* Generates pagination metadata for a given query and current page.
|
|
4
|
+
* It builds a list of pages to display and determines whether "next" and "previous" buttons should be shown.
|
|
5
|
+
* The resulting object can be used to render a pagination UI.
|
|
6
|
+
*
|
|
7
|
+
* @param {string} query - The base query string to be appended to URLs (without `?` or `&`).
|
|
8
|
+
* @param {number} page - The current page number.
|
|
9
|
+
* @param {number} total - The total number of pages.
|
|
10
|
+
* @param {string} [url=''] - The base URL to which pagination parameters will be added.
|
|
11
|
+
* @param {string} [extraClass=''] - Additional class name for styling the pagination container.
|
|
12
|
+
* @param {string} [extraClass2=''] - Additional class name for individual page links.
|
|
13
|
+
*
|
|
14
|
+
* @returns {Object} Pagination metadata including:
|
|
15
|
+
* - `url` {string} - The updated URL prefix to use for each page link.
|
|
16
|
+
* - `extraClass` {string} - Additional class name passed through.
|
|
17
|
+
* - `extraClass2` {string} - Additional class name passed through.
|
|
18
|
+
* - `page` {number} - The current page.
|
|
19
|
+
* - `pagination` {number[]} - An array of page numbers to be displayed.
|
|
20
|
+
* - `previous` {boolean} - Whether there are previous pages.
|
|
21
|
+
* - `next` {boolean} - Whether there are next pages.
|
|
22
|
+
* - `firstPagination` {boolean} - `true` if page 1 is not in the visible pagination and should be shown separately.
|
|
23
|
+
* - `lastPagination` {boolean} - `true` if the last page is not in the visible pagination and should be shown separately.
|
|
24
|
+
* - `pages` {number} - Total number of pages.
|
|
25
|
+
*/
|
|
26
|
+
export default function pagination(query, page, total, url = '', extraClass = '', extraClass2 = '') {
|
|
27
|
+
// Fix URL
|
|
28
|
+
if (url) {
|
|
29
|
+
// Final URL Result
|
|
30
|
+
const finalURLResult = function (sqT = '') {
|
|
31
|
+
if (query)
|
|
32
|
+
return sqT + query + '&page=';
|
|
33
|
+
else
|
|
34
|
+
return 'page=';
|
|
35
|
+
};
|
|
36
|
+
// Param Fixed
|
|
37
|
+
const params = queryUrlJSON(url);
|
|
38
|
+
if (Object.keys(params).length > 0) {
|
|
39
|
+
if (params.page) {
|
|
40
|
+
url = url
|
|
41
|
+
.replace(finalURLResult('&') + params.page, '')
|
|
42
|
+
.replace('?' + query + '=' + params.page, '?')
|
|
43
|
+
.replace('?&', '?');
|
|
44
|
+
if (Object.keys(params).length === 1)
|
|
45
|
+
url += finalURLResult();
|
|
46
|
+
else
|
|
47
|
+
url += finalURLResult('&');
|
|
48
|
+
}
|
|
49
|
+
else
|
|
50
|
+
url += finalURLResult('&');
|
|
51
|
+
}
|
|
52
|
+
else
|
|
53
|
+
url += finalURLResult('?');
|
|
54
|
+
}
|
|
55
|
+
// Pagination
|
|
56
|
+
const pagination = [];
|
|
57
|
+
const data = {
|
|
58
|
+
url: url,
|
|
59
|
+
extraClass: extraClass,
|
|
60
|
+
extraClass2: extraClass2,
|
|
61
|
+
};
|
|
62
|
+
data.next = false;
|
|
63
|
+
data.previous = false;
|
|
64
|
+
for (let i = page - 1; i > page - 5; i--) {
|
|
65
|
+
if (i > 0) {
|
|
66
|
+
pagination.push(i);
|
|
67
|
+
data.previous = true;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
pagination.reverse();
|
|
71
|
+
pagination.push(page);
|
|
72
|
+
for (let i = page + 1; i < page + 5; i++) {
|
|
73
|
+
if (i <= total) {
|
|
74
|
+
pagination.push(i);
|
|
75
|
+
data.next = true;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
// Build Data and send it
|
|
79
|
+
data.page = page;
|
|
80
|
+
data.pagination = pagination;
|
|
81
|
+
if (pagination.indexOf(1) < 0)
|
|
82
|
+
data.firstPagination = true;
|
|
83
|
+
else
|
|
84
|
+
data.firstPagination = false;
|
|
85
|
+
if (pagination.indexOf(total) < 0)
|
|
86
|
+
data.lastPagination = true;
|
|
87
|
+
else
|
|
88
|
+
data.lastPagination = false;
|
|
89
|
+
data.pages = total;
|
|
90
|
+
return data;
|
|
91
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Extracts the value of a specific query parameter from a URL.
|
|
5
|
+
*
|
|
6
|
+
* - Supports parameter names with brackets (e.g. `arr[0]`).
|
|
7
|
+
* - Returns `null` if the parameter is not found.
|
|
8
|
+
* - Returns an empty string if the parameter exists without a value.
|
|
9
|
+
*
|
|
10
|
+
* Examples:
|
|
11
|
+
* ```js
|
|
12
|
+
* queryUrlByName('foo', 'http://example.com/?foo=bar'); // "bar"
|
|
13
|
+
* queryUrlByName('foo', 'http://example.com/?foo='); // ""
|
|
14
|
+
* queryUrlByName('foo', 'http://example.com/'); // null
|
|
15
|
+
* queryUrlByName('arr[0]', 'http://x.com/?arr[0]=yes'); // "yes"
|
|
16
|
+
* ```
|
|
17
|
+
*
|
|
18
|
+
* @param {string} name - The name of the query parameter to retrieve.
|
|
19
|
+
* @param {string} url - The full URL from which to extract the parameter.
|
|
20
|
+
* @returns {string|null} The decoded value of the parameter, or `null` if not found.
|
|
21
|
+
*/
|
|
22
|
+
function queryUrlByName(name, url) {
|
|
23
|
+
let newName = name.replace(/[\[\]]/g, '\\$&');
|
|
24
|
+
var regex = new RegExp('[?&]' + newName + '(=([^&#]*)|&|#|$)'),
|
|
25
|
+
results = regex.exec(url);
|
|
26
|
+
if (!results) return null;
|
|
27
|
+
if (!results[2]) return '';
|
|
28
|
+
return decodeURIComponent(results[2].replace(/\+/g, ' '));
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
module.exports = queryUrlByName;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Extracts the value of a specific query parameter from a URL.
|
|
3
|
+
*
|
|
4
|
+
* - Supports parameter names with brackets (e.g. `arr[0]`).
|
|
5
|
+
* - Returns `null` if the parameter is not found.
|
|
6
|
+
* - Returns an empty string if the parameter exists without a value.
|
|
7
|
+
*
|
|
8
|
+
* Examples:
|
|
9
|
+
* ```js
|
|
10
|
+
* queryUrlByName('foo', 'http://example.com/?foo=bar'); // "bar"
|
|
11
|
+
* queryUrlByName('foo', 'http://example.com/?foo='); // ""
|
|
12
|
+
* queryUrlByName('foo', 'http://example.com/'); // null
|
|
13
|
+
* queryUrlByName('arr[0]', 'http://x.com/?arr[0]=yes'); // "yes"
|
|
14
|
+
* ```
|
|
15
|
+
*
|
|
16
|
+
* @param {string} name - The name of the query parameter to retrieve.
|
|
17
|
+
* @param {string} url - The full URL from which to extract the parameter.
|
|
18
|
+
* @returns {string|null} The decoded value of the parameter, or `null` if not found.
|
|
19
|
+
*/
|
|
20
|
+
export default function queryUrlByName(name: string, url: string): string | null;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Extracts the value of a specific query parameter from a URL.
|
|
3
|
+
*
|
|
4
|
+
* - Supports parameter names with brackets (e.g. `arr[0]`).
|
|
5
|
+
* - Returns `null` if the parameter is not found.
|
|
6
|
+
* - Returns an empty string if the parameter exists without a value.
|
|
7
|
+
*
|
|
8
|
+
* Examples:
|
|
9
|
+
* ```js
|
|
10
|
+
* queryUrlByName('foo', 'http://example.com/?foo=bar'); // "bar"
|
|
11
|
+
* queryUrlByName('foo', 'http://example.com/?foo='); // ""
|
|
12
|
+
* queryUrlByName('foo', 'http://example.com/'); // null
|
|
13
|
+
* queryUrlByName('arr[0]', 'http://x.com/?arr[0]=yes'); // "yes"
|
|
14
|
+
* ```
|
|
15
|
+
*
|
|
16
|
+
* @param {string} name - The name of the query parameter to retrieve.
|
|
17
|
+
* @param {string} url - The full URL from which to extract the parameter.
|
|
18
|
+
* @returns {string|null} The decoded value of the parameter, or `null` if not found.
|
|
19
|
+
*/
|
|
20
|
+
export default function queryUrlByName(name, url) {
|
|
21
|
+
let newName = name.replace(/[\[\]]/g, '\\$&');
|
|
22
|
+
var regex = new RegExp('[?&]' + newName + '(=([^&#]*)|&|#|$)'), results = regex.exec(url);
|
|
23
|
+
if (!results)
|
|
24
|
+
return null;
|
|
25
|
+
if (!results[2])
|
|
26
|
+
return '';
|
|
27
|
+
return decodeURIComponent(results[2].replace(/\+/g, ' '));
|
|
28
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Parses the query string from a URL into a JSON object.
|
|
5
|
+
*
|
|
6
|
+
* - Supports `key=value` pairs.
|
|
7
|
+
* - Supports array syntax (`arr[]=1&arr[]=2`, or `arr[1]=x`).
|
|
8
|
+
* - Ignores fragments (`#`).
|
|
9
|
+
* - If no URL is passed, uses `window.location.href` by default.
|
|
10
|
+
*
|
|
11
|
+
* Examples:
|
|
12
|
+
* ```js
|
|
13
|
+
* queryUrlJSON('http://example.com/?name=John&colors[]=red&colors[]=blue');
|
|
14
|
+
* // => { name: 'John', colors: ['red', 'blue'] }
|
|
15
|
+
*
|
|
16
|
+
* queryUrlJSON('http://x.com/?arr[1]=a&arr[0]=b');
|
|
17
|
+
* // => { arr: ['b', 'a'] }
|
|
18
|
+
* ```
|
|
19
|
+
*
|
|
20
|
+
* @param {string} [url=location.href] - The full URL to parse.
|
|
21
|
+
* @returns {Object.<string, string|string[]>} A key-value object representing the parsed query.
|
|
22
|
+
*/
|
|
23
|
+
function queryUrlJSON(url) {
|
|
24
|
+
if (!url) url = location.href;
|
|
25
|
+
var question = url.indexOf('?');
|
|
26
|
+
var hash = url.indexOf('#');
|
|
27
|
+
if (hash === -1 && question === -1) return {};
|
|
28
|
+
if (hash === -1) hash = url.length;
|
|
29
|
+
var query =
|
|
30
|
+
question === -1 || hash === question + 1
|
|
31
|
+
? url.substring(hash)
|
|
32
|
+
: url.substring(question + 1, hash);
|
|
33
|
+
var result = {};
|
|
34
|
+
query.split('&').forEach((part) => {
|
|
35
|
+
if (!part) return;
|
|
36
|
+
part = part.split('+').join(' '); // replace every + with space, regexp-free version
|
|
37
|
+
var eq = part.indexOf('=');
|
|
38
|
+
var key = eq > -1 ? part.substr(0, eq) : part;
|
|
39
|
+
var val = eq > -1 ? decodeURIComponent(part.substr(eq + 1)) : '';
|
|
40
|
+
var from = key.indexOf('[');
|
|
41
|
+
if (from === -1) result[decodeURIComponent(key)] = val;
|
|
42
|
+
else {
|
|
43
|
+
var to = key.indexOf(']', from);
|
|
44
|
+
var index = decodeURIComponent(key.substring(from + 1, to));
|
|
45
|
+
key = decodeURIComponent(key.substring(0, from));
|
|
46
|
+
if (!result[key]) result[key] = [];
|
|
47
|
+
if (!index) result[key].push(val);
|
|
48
|
+
else result[key][index] = val;
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
return result;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
module.exports = queryUrlJSON;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Parses the query string from a URL into a JSON object.
|
|
3
|
+
*
|
|
4
|
+
* - Supports `key=value` pairs.
|
|
5
|
+
* - Supports array syntax (`arr[]=1&arr[]=2`, or `arr[1]=x`).
|
|
6
|
+
* - Ignores fragments (`#`).
|
|
7
|
+
* - If no URL is passed, uses `window.location.href` by default.
|
|
8
|
+
*
|
|
9
|
+
* Examples:
|
|
10
|
+
* ```js
|
|
11
|
+
* queryUrlJSON('http://example.com/?name=John&colors[]=red&colors[]=blue');
|
|
12
|
+
* // => { name: 'John', colors: ['red', 'blue'] }
|
|
13
|
+
*
|
|
14
|
+
* queryUrlJSON('http://x.com/?arr[1]=a&arr[0]=b');
|
|
15
|
+
* // => { arr: ['b', 'a'] }
|
|
16
|
+
* ```
|
|
17
|
+
*
|
|
18
|
+
* @param {string} [url=location.href] - The full URL to parse.
|
|
19
|
+
* @returns {Object.<string, string|string[]>} A key-value object representing the parsed query.
|
|
20
|
+
*/
|
|
21
|
+
export default function queryUrlJSON(url?: string): {
|
|
22
|
+
[x: string]: string | string[];
|
|
23
|
+
};
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Parses the query string from a URL into a JSON object.
|
|
3
|
+
*
|
|
4
|
+
* - Supports `key=value` pairs.
|
|
5
|
+
* - Supports array syntax (`arr[]=1&arr[]=2`, or `arr[1]=x`).
|
|
6
|
+
* - Ignores fragments (`#`).
|
|
7
|
+
* - If no URL is passed, uses `window.location.href` by default.
|
|
8
|
+
*
|
|
9
|
+
* Examples:
|
|
10
|
+
* ```js
|
|
11
|
+
* queryUrlJSON('http://example.com/?name=John&colors[]=red&colors[]=blue');
|
|
12
|
+
* // => { name: 'John', colors: ['red', 'blue'] }
|
|
13
|
+
*
|
|
14
|
+
* queryUrlJSON('http://x.com/?arr[1]=a&arr[0]=b');
|
|
15
|
+
* // => { arr: ['b', 'a'] }
|
|
16
|
+
* ```
|
|
17
|
+
*
|
|
18
|
+
* @param {string} [url=location.href] - The full URL to parse.
|
|
19
|
+
* @returns {Object.<string, string|string[]>} A key-value object representing the parsed query.
|
|
20
|
+
*/
|
|
21
|
+
export default function queryUrlJSON(url) {
|
|
22
|
+
if (!url)
|
|
23
|
+
url = location.href;
|
|
24
|
+
var question = url.indexOf('?');
|
|
25
|
+
var hash = url.indexOf('#');
|
|
26
|
+
if (hash === -1 && question === -1)
|
|
27
|
+
return {};
|
|
28
|
+
if (hash === -1)
|
|
29
|
+
hash = url.length;
|
|
30
|
+
var query = question === -1 || hash === question + 1
|
|
31
|
+
? url.substring(hash)
|
|
32
|
+
: url.substring(question + 1, hash);
|
|
33
|
+
var result = {};
|
|
34
|
+
query.split('&').forEach((part) => {
|
|
35
|
+
if (!part)
|
|
36
|
+
return;
|
|
37
|
+
part = part.split('+').join(' '); // replace every + with space, regexp-free version
|
|
38
|
+
var eq = part.indexOf('=');
|
|
39
|
+
var key = eq > -1 ? part.substr(0, eq) : part;
|
|
40
|
+
var val = eq > -1 ? decodeURIComponent(part.substr(eq + 1)) : '';
|
|
41
|
+
var from = key.indexOf('[');
|
|
42
|
+
if (from === -1)
|
|
43
|
+
result[decodeURIComponent(key)] = val;
|
|
44
|
+
else {
|
|
45
|
+
var to = key.indexOf(']', from);
|
|
46
|
+
var index = decodeURIComponent(key.substring(from + 1, to));
|
|
47
|
+
key = decodeURIComponent(key.substring(0, from));
|
|
48
|
+
if (!result[key])
|
|
49
|
+
result[key] = [];
|
|
50
|
+
if (!index)
|
|
51
|
+
result[key].push(val);
|
|
52
|
+
else
|
|
53
|
+
result[key][index] = val;
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
return result;
|
|
57
|
+
}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var objType = require('./objType.cjs');
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Filters a list of strings by comparing each item against a list of validators.
|
|
7
|
+
*
|
|
8
|
+
* Each validator can be either:
|
|
9
|
+
* - A **string** (for exact match)
|
|
10
|
+
* - An **object** with one or more of the following:
|
|
11
|
+
* - `starts`: {string} - The string must start with this prefix.
|
|
12
|
+
* - `ends`: {string} - The string must end with this suffix.
|
|
13
|
+
* - `regexp`: {RegExp} - The string must match the regular expression.
|
|
14
|
+
*
|
|
15
|
+
* The comparison stops at the first matching validator per item.
|
|
16
|
+
*
|
|
17
|
+
* Examples:
|
|
18
|
+
* ```js
|
|
19
|
+
* super_string_filter(['apple', 'banana', 'blueberry'], ['banana']); // ['banana']
|
|
20
|
+
* super_string_filter(['apple', 'banana'], [{ starts: 'app' }]); // ['apple']
|
|
21
|
+
* super_string_filter(['test.js'], [{ ends: '.js' }]); // ['test.js']
|
|
22
|
+
* super_string_filter(['data123'], [{ regexp: /^\w+\d+$/ }]); // ['data123']
|
|
23
|
+
* ```
|
|
24
|
+
*
|
|
25
|
+
* @param {string[]} list - The list of strings to filter.
|
|
26
|
+
* @param {(string|Object)[]} validator_list - The list of validators.
|
|
27
|
+
* @returns {string[]} A filtered array of strings that passed at least one validator.
|
|
28
|
+
*/
|
|
29
|
+
function super_string_filter(list, validator_list) {
|
|
30
|
+
// Result
|
|
31
|
+
const result = [];
|
|
32
|
+
|
|
33
|
+
// The For
|
|
34
|
+
for (const item in list) {
|
|
35
|
+
for (const item2 in validator_list) {
|
|
36
|
+
// Check Types
|
|
37
|
+
|
|
38
|
+
// String
|
|
39
|
+
if (typeof validator_list[item2] === 'string') {
|
|
40
|
+
if (list[item] === validator_list[item2]) {
|
|
41
|
+
result.push(validator_list[item2]);
|
|
42
|
+
break;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
// Object
|
|
47
|
+
else if (objType(validator_list[item2], 'object')) {
|
|
48
|
+
// Validator
|
|
49
|
+
const tiny_validator = {};
|
|
50
|
+
|
|
51
|
+
// Starts With
|
|
52
|
+
tiny_validator.starts = {};
|
|
53
|
+
tiny_validator.starts.enabled = typeof validator_list[item2].starts === 'string';
|
|
54
|
+
if (tiny_validator.starts.enabled) {
|
|
55
|
+
tiny_validator.starts.result = list[item].startsWith(validator_list[item2].starts);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
// Ends With
|
|
59
|
+
tiny_validator.ends = {};
|
|
60
|
+
tiny_validator.ends.enabled = typeof validator_list[item2].ends === 'string';
|
|
61
|
+
if (tiny_validator.ends.enabled) {
|
|
62
|
+
tiny_validator.ends.result = list[item].endsWith(validator_list[item2].ends);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
// RegExp
|
|
66
|
+
tiny_validator.regexp = {};
|
|
67
|
+
tiny_validator.regexp.enabled = objType(validator_list[item2].regexp, 'regexp');
|
|
68
|
+
if (tiny_validator.regexp.enabled) {
|
|
69
|
+
tiny_validator.regexp.result = list[item].match(validator_list[item2].regexp);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
// Check Validator
|
|
73
|
+
let allowed_timezone = true;
|
|
74
|
+
for (const item3 in tiny_validator) {
|
|
75
|
+
if (tiny_validator[item3].enabled) {
|
|
76
|
+
// Invalid Result
|
|
77
|
+
if (!tiny_validator[item3].result) {
|
|
78
|
+
allowed_timezone = false;
|
|
79
|
+
break;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
// Start With
|
|
85
|
+
if (allowed_timezone) {
|
|
86
|
+
result.push(list[item]);
|
|
87
|
+
break;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
// Result
|
|
94
|
+
return result;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
module.exports = super_string_filter;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Filters a list of strings by comparing each item against a list of validators.
|
|
3
|
+
*
|
|
4
|
+
* Each validator can be either:
|
|
5
|
+
* - A **string** (for exact match)
|
|
6
|
+
* - An **object** with one or more of the following:
|
|
7
|
+
* - `starts`: {string} - The string must start with this prefix.
|
|
8
|
+
* - `ends`: {string} - The string must end with this suffix.
|
|
9
|
+
* - `regexp`: {RegExp} - The string must match the regular expression.
|
|
10
|
+
*
|
|
11
|
+
* The comparison stops at the first matching validator per item.
|
|
12
|
+
*
|
|
13
|
+
* Examples:
|
|
14
|
+
* ```js
|
|
15
|
+
* super_string_filter(['apple', 'banana', 'blueberry'], ['banana']); // ['banana']
|
|
16
|
+
* super_string_filter(['apple', 'banana'], [{ starts: 'app' }]); // ['apple']
|
|
17
|
+
* super_string_filter(['test.js'], [{ ends: '.js' }]); // ['test.js']
|
|
18
|
+
* super_string_filter(['data123'], [{ regexp: /^\w+\d+$/ }]); // ['data123']
|
|
19
|
+
* ```
|
|
20
|
+
*
|
|
21
|
+
* @param {string[]} list - The list of strings to filter.
|
|
22
|
+
* @param {(string|Object)[]} validator_list - The list of validators.
|
|
23
|
+
* @returns {string[]} A filtered array of strings that passed at least one validator.
|
|
24
|
+
*/
|
|
25
|
+
export default function super_string_filter(list: string[], validator_list: (string | Object)[]): string[];
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import objType from './objType.mjs';
|
|
2
|
+
/**
|
|
3
|
+
* Filters a list of strings by comparing each item against a list of validators.
|
|
4
|
+
*
|
|
5
|
+
* Each validator can be either:
|
|
6
|
+
* - A **string** (for exact match)
|
|
7
|
+
* - An **object** with one or more of the following:
|
|
8
|
+
* - `starts`: {string} - The string must start with this prefix.
|
|
9
|
+
* - `ends`: {string} - The string must end with this suffix.
|
|
10
|
+
* - `regexp`: {RegExp} - The string must match the regular expression.
|
|
11
|
+
*
|
|
12
|
+
* The comparison stops at the first matching validator per item.
|
|
13
|
+
*
|
|
14
|
+
* Examples:
|
|
15
|
+
* ```js
|
|
16
|
+
* super_string_filter(['apple', 'banana', 'blueberry'], ['banana']); // ['banana']
|
|
17
|
+
* super_string_filter(['apple', 'banana'], [{ starts: 'app' }]); // ['apple']
|
|
18
|
+
* super_string_filter(['test.js'], [{ ends: '.js' }]); // ['test.js']
|
|
19
|
+
* super_string_filter(['data123'], [{ regexp: /^\w+\d+$/ }]); // ['data123']
|
|
20
|
+
* ```
|
|
21
|
+
*
|
|
22
|
+
* @param {string[]} list - The list of strings to filter.
|
|
23
|
+
* @param {(string|Object)[]} validator_list - The list of validators.
|
|
24
|
+
* @returns {string[]} A filtered array of strings that passed at least one validator.
|
|
25
|
+
*/
|
|
26
|
+
export default function super_string_filter(list, validator_list) {
|
|
27
|
+
// Result
|
|
28
|
+
const result = [];
|
|
29
|
+
// The For
|
|
30
|
+
for (const item in list) {
|
|
31
|
+
for (const item2 in validator_list) {
|
|
32
|
+
// Check Types
|
|
33
|
+
// String
|
|
34
|
+
if (typeof validator_list[item2] === 'string') {
|
|
35
|
+
if (list[item] === validator_list[item2]) {
|
|
36
|
+
result.push(validator_list[item2]);
|
|
37
|
+
break;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
// Object
|
|
41
|
+
else if (objType(validator_list[item2], 'object')) {
|
|
42
|
+
// Validator
|
|
43
|
+
const tiny_validator = {};
|
|
44
|
+
// Starts With
|
|
45
|
+
tiny_validator.starts = {};
|
|
46
|
+
tiny_validator.starts.enabled = typeof validator_list[item2].starts === 'string';
|
|
47
|
+
if (tiny_validator.starts.enabled) {
|
|
48
|
+
tiny_validator.starts.result = list[item].startsWith(validator_list[item2].starts);
|
|
49
|
+
}
|
|
50
|
+
// Ends With
|
|
51
|
+
tiny_validator.ends = {};
|
|
52
|
+
tiny_validator.ends.enabled = typeof validator_list[item2].ends === 'string';
|
|
53
|
+
if (tiny_validator.ends.enabled) {
|
|
54
|
+
tiny_validator.ends.result = list[item].endsWith(validator_list[item2].ends);
|
|
55
|
+
}
|
|
56
|
+
// RegExp
|
|
57
|
+
tiny_validator.regexp = {};
|
|
58
|
+
tiny_validator.regexp.enabled = objType(validator_list[item2].regexp, 'regexp');
|
|
59
|
+
if (tiny_validator.regexp.enabled) {
|
|
60
|
+
tiny_validator.regexp.result = list[item].match(validator_list[item2].regexp);
|
|
61
|
+
}
|
|
62
|
+
// Check Validator
|
|
63
|
+
let allowed_timezone = true;
|
|
64
|
+
for (const item3 in tiny_validator) {
|
|
65
|
+
if (tiny_validator[item3].enabled) {
|
|
66
|
+
// Invalid Result
|
|
67
|
+
if (!tiny_validator[item3].result) {
|
|
68
|
+
allowed_timezone = false;
|
|
69
|
+
break;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
// Start With
|
|
74
|
+
if (allowed_timezone) {
|
|
75
|
+
result.push(list[item]);
|
|
76
|
+
break;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
// Result
|
|
82
|
+
return result;
|
|
83
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var latestVersion = require('latest-version');
|
|
4
|
+
var compareVersions = require('compare-versions');
|
|
5
|
+
var moment = require('moment');
|
|
6
|
+
|
|
7
|
+
// Modules
|
|
8
|
+
|
|
9
|
+
// Check Version
|
|
10
|
+
const check_version = {
|
|
11
|
+
v: null,
|
|
12
|
+
t: null,
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Checks if the package version is up-to-date by comparing it with the latest version available on npm.
|
|
17
|
+
* The version check is cached and updated every hour.
|
|
18
|
+
*
|
|
19
|
+
* @param {Object} pkg - The package information.
|
|
20
|
+
* @param {string} pkg.name - The name of the package.
|
|
21
|
+
* @param {string} pkg.version - The current version of the package.
|
|
22
|
+
*
|
|
23
|
+
* @returns {Promise<Object>} The result object containing:
|
|
24
|
+
* - `needUpdate`: {boolean} - `true` if the current version is outdated, `false` otherwise.
|
|
25
|
+
* - `now`: {string} - The current version of the package.
|
|
26
|
+
* - `new`: {string} - The latest version of the package available on npm.
|
|
27
|
+
*/
|
|
28
|
+
async function versionCheck(pkg) {
|
|
29
|
+
// Time Now
|
|
30
|
+
const now = moment();
|
|
31
|
+
|
|
32
|
+
// Check Version
|
|
33
|
+
if (!check_version.t || now.diff(check_version.t, 'hours') > 0) {
|
|
34
|
+
check_version.t = now.add(1, 'hours');
|
|
35
|
+
check_version.v = await latestVersion(pkg.name);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
// Insert Version
|
|
39
|
+
const result = { needUpdate: compareVersions.compare(pkg.version, check_version.v, '<') };
|
|
40
|
+
|
|
41
|
+
// Allowed Show Version
|
|
42
|
+
result.now = pkg.version;
|
|
43
|
+
result.new = check_version.v;
|
|
44
|
+
|
|
45
|
+
// Return
|
|
46
|
+
return result;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
module.exports = versionCheck;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Checks if the package version is up-to-date by comparing it with the latest version available on npm.
|
|
3
|
+
* The version check is cached and updated every hour.
|
|
4
|
+
*
|
|
5
|
+
* @param {Object} pkg - The package information.
|
|
6
|
+
* @param {string} pkg.name - The name of the package.
|
|
7
|
+
* @param {string} pkg.version - The current version of the package.
|
|
8
|
+
*
|
|
9
|
+
* @returns {Promise<Object>} The result object containing:
|
|
10
|
+
* - `needUpdate`: {boolean} - `true` if the current version is outdated, `false` otherwise.
|
|
11
|
+
* - `now`: {string} - The current version of the package.
|
|
12
|
+
* - `new`: {string} - The latest version of the package available on npm.
|
|
13
|
+
*/
|
|
14
|
+
export default function versionCheck(pkg: {
|
|
15
|
+
name: string;
|
|
16
|
+
version: string;
|
|
17
|
+
}): Promise<Object>;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
// Modules
|
|
2
|
+
import latestVersion from 'latest-version';
|
|
3
|
+
import { compare } from 'compare-versions';
|
|
4
|
+
import moment from 'moment';
|
|
5
|
+
// Check Version
|
|
6
|
+
const check_version = {
|
|
7
|
+
v: null,
|
|
8
|
+
t: null,
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* Checks if the package version is up-to-date by comparing it with the latest version available on npm.
|
|
12
|
+
* The version check is cached and updated every hour.
|
|
13
|
+
*
|
|
14
|
+
* @param {Object} pkg - The package information.
|
|
15
|
+
* @param {string} pkg.name - The name of the package.
|
|
16
|
+
* @param {string} pkg.version - The current version of the package.
|
|
17
|
+
*
|
|
18
|
+
* @returns {Promise<Object>} The result object containing:
|
|
19
|
+
* - `needUpdate`: {boolean} - `true` if the current version is outdated, `false` otherwise.
|
|
20
|
+
* - `now`: {string} - The current version of the package.
|
|
21
|
+
* - `new`: {string} - The latest version of the package available on npm.
|
|
22
|
+
*/
|
|
23
|
+
export default async function versionCheck(pkg) {
|
|
24
|
+
// Time Now
|
|
25
|
+
const now = moment();
|
|
26
|
+
// Check Version
|
|
27
|
+
if (!check_version.t || now.diff(check_version.t, 'hours') > 0) {
|
|
28
|
+
check_version.t = now.add(1, 'hours');
|
|
29
|
+
check_version.v = await latestVersion(pkg.name);
|
|
30
|
+
}
|
|
31
|
+
// Insert Version
|
|
32
|
+
const result = { needUpdate: compare(pkg.version, check_version.v, '<') };
|
|
33
|
+
// Allowed Show Version
|
|
34
|
+
result.now = pkg.version;
|
|
35
|
+
result.new = check_version.v;
|
|
36
|
+
// Return
|
|
37
|
+
return result;
|
|
38
|
+
}
|