tiny-essentials 1.1.1 → 1.2.1
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/README.md +3 -1
- package/dist/TinyBasicsEs.js +2821 -0
- package/dist/TinyBasicsEs.min.js +2 -0
- package/dist/TinyBasicsEs.min.js.LICENSE.txt +8 -0
- package/dist/TinyCertCrypto.js +31364 -0
- package/dist/TinyCertCrypto.min.js +2 -0
- package/dist/TinyCertCrypto.min.js.LICENSE.txt +8 -0
- package/dist/TinyCrypto.js +48138 -0
- package/dist/TinyCrypto.min.js +2 -0
- package/dist/TinyCrypto.min.js.LICENSE.txt +10 -0
- package/dist/TinyEssentials.js +77695 -0
- package/dist/TinyEssentials.min.js +2 -1
- package/dist/TinyEssentials.min.js.LICENSE.txt +10 -0
- package/dist/TinyLevelUp.js +173 -0
- package/dist/TinyLevelUp.min.js +1 -0
- package/dist/legacy/crypto/decrypt.cjs +1 -0
- package/dist/legacy/crypto/decrypt.mjs +1 -0
- package/dist/legacy/crypto/default.cjs +2 -0
- package/dist/legacy/crypto/default.mjs +1 -0
- package/dist/legacy/crypto/encrypt.cjs +2 -1
- package/dist/legacy/crypto/encrypt.mjs +1 -0
- package/dist/legacy/crypto/index.cjs +1 -1
- package/dist/legacy/crypto/index.mjs +1 -0
- package/dist/legacy/firebase/cookieSession.cjs +2 -0
- package/dist/legacy/firebase/cookieSession.mjs +1 -0
- package/dist/legacy/firebase/database/index.cjs +3 -0
- package/dist/legacy/firebase/database/index.mjs +1 -0
- package/dist/legacy/firebase/database/presence.cjs +3 -0
- package/dist/legacy/firebase/database/presence.mjs +1 -0
- package/dist/legacy/firebase/database/saveAsync.cjs +2 -0
- package/dist/legacy/firebase/database/saveAsync.mjs +1 -0
- package/dist/legacy/firebase/databaseEscape.cjs +3 -0
- package/dist/legacy/firebase/databaseEscape.mjs +1 -0
- package/dist/legacy/firebase/databaseLogger.cjs +3 -0
- package/dist/legacy/firebase/databaseLogger.mjs +1 -0
- package/dist/legacy/firebase/discord/api/addGuildMember.cjs +3 -0
- package/dist/legacy/firebase/discord/api/addGuildMember.mjs +1 -0
- package/dist/legacy/firebase/discord/api/getGuildWidget.cjs +3 -0
- package/dist/legacy/firebase/discord/api/getGuildWidget.mjs +1 -0
- package/dist/legacy/firebase/discord/api/getToken.cjs +3 -0
- package/dist/legacy/firebase/discord/api/getToken.mjs +1 -0
- package/dist/legacy/firebase/discord/api/getUser.cjs +3 -0
- package/dist/legacy/firebase/discord/api/getUser.mjs +1 -0
- package/dist/legacy/firebase/discord/api/getUserConnections.cjs +3 -0
- package/dist/legacy/firebase/discord/api/getUserConnections.mjs +1 -0
- package/dist/legacy/firebase/discord/api/getUserGuilds.cjs +3 -0
- package/dist/legacy/firebase/discord/api/getUserGuilds.mjs +1 -0
- package/dist/legacy/firebase/discord/api/index.cjs +3 -0
- package/dist/legacy/firebase/discord/api/index.mjs +1 -0
- package/dist/legacy/firebase/discord/api/refreshToken.cjs +3 -0
- package/dist/legacy/firebase/discord/api/refreshToken.mjs +1 -0
- package/dist/legacy/firebase/discord/api/revokeToken.cjs +3 -0
- package/dist/legacy/firebase/discord/api/revokeToken.mjs +1 -0
- package/dist/legacy/firebase/discord/config.cjs +2 -0
- package/dist/legacy/firebase/discord/config.mjs +1 -0
- package/dist/legacy/firebase/discord/firebase_redirect/index.cjs +3 -0
- package/dist/legacy/firebase/discord/firebase_redirect/index.mjs +1 -0
- package/dist/legacy/firebase/discord/firebase_redirect/login.cjs +2 -0
- package/dist/legacy/firebase/discord/firebase_redirect/login.mjs +1 -0
- package/dist/legacy/firebase/discord/firebase_redirect/logout.cjs +2 -0
- package/dist/legacy/firebase/discord/firebase_redirect/logout.mjs +1 -0
- package/dist/legacy/firebase/discord/get/authURLGenerator.cjs +3 -0
- package/dist/legacy/firebase/discord/get/authURLGenerator.mjs +1 -0
- package/dist/legacy/firebase/discord/get/cookie-session.cjs +3 -0
- package/dist/legacy/firebase/discord/get/cookie-session.mjs +1 -0
- package/dist/legacy/firebase/discord/get/credentials.cjs +2 -0
- package/dist/legacy/firebase/discord/get/credentials.mjs +1 -0
- package/dist/legacy/firebase/discord/get/errorValidator.cjs +3 -0
- package/dist/legacy/firebase/discord/get/errorValidator.mjs +1 -0
- package/dist/legacy/firebase/discord/get/index.cjs +3 -0
- package/dist/legacy/firebase/discord/get/index.mjs +1 -0
- package/dist/legacy/firebase/discord/get/randomAvatar.cjs +3 -0
- package/dist/legacy/firebase/discord/get/randomAvatar.mjs +1 -0
- package/dist/legacy/firebase/discord/http/index.cjs +3 -0
- package/dist/legacy/firebase/discord/http/index.mjs +1 -0
- package/dist/legacy/firebase/discord/http/login.cjs +3 -0
- package/dist/legacy/firebase/discord/http/login.mjs +1 -0
- package/dist/legacy/firebase/discord/http/logout.cjs +3 -0
- package/dist/legacy/firebase/discord/http/logout.mjs +1 -0
- package/dist/legacy/firebase/discord/http/redirect.cjs +3 -0
- package/dist/legacy/firebase/discord/http/redirect.mjs +1 -0
- package/dist/legacy/firebase/discord/http/refreshToken.cjs +3 -0
- package/dist/legacy/firebase/discord/http/refreshToken.mjs +1 -0
- package/dist/legacy/firebase/discord/index.cjs +3 -0
- package/dist/legacy/firebase/discord/index.mjs +1 -0
- package/dist/legacy/firebase/discord/template/cookie-session.cjs +3 -0
- package/dist/legacy/firebase/discord/template/cookie-session.mjs +1 -0
- package/dist/legacy/firebase/domainRedirect.cjs +2 -0
- package/dist/legacy/firebase/domainRedirect.mjs +1 -0
- package/dist/legacy/firebase/escape.cjs +2 -0
- package/dist/legacy/firebase/escape.mjs +1 -0
- package/dist/legacy/firebase/getDBAsync.cjs +2 -0
- package/dist/legacy/firebase/getDBAsync.mjs +1 -0
- package/dist/legacy/firebase/getDBData.cjs +3 -0
- package/dist/legacy/firebase/getDBData.mjs +1 -0
- package/dist/legacy/firebase/getDBValue.cjs +2 -0
- package/dist/legacy/firebase/getDBValue.mjs +1 -0
- package/dist/legacy/firebase/index.cjs +3 -0
- package/dist/legacy/firebase/index.mjs +1 -0
- package/dist/legacy/firebase/isEmulator.cjs +2 -0
- package/dist/legacy/firebase/isEmulator.mjs +1 -0
- package/dist/legacy/firebase/logger.cjs +3 -0
- package/dist/legacy/firebase/logger.mjs +1 -0
- package/dist/legacy/firebase/mySQL.cjs +3 -0
- package/dist/legacy/firebase/mySQL.mjs +1 -0
- package/dist/legacy/firebase/mysqlConnector/create.cjs +2 -0
- package/dist/legacy/firebase/mysqlConnector/create.mjs +1 -0
- package/dist/legacy/firebase/mysqlConnector/index.cjs +3 -0
- package/dist/legacy/firebase/mysqlConnector/index.mjs +1 -0
- package/dist/legacy/firebase/mysqlConnector/nextPrev.cjs +2 -0
- package/dist/legacy/firebase/mysqlConnector/nextPrev.mjs +1 -0
- package/dist/legacy/firebase/mysqlConnector/pagination.cjs +2 -0
- package/dist/legacy/firebase/mysqlConnector/pagination.mjs +1 -0
- package/dist/legacy/firebase/mysqlConnector/sameUser.cjs +3 -0
- package/dist/legacy/firebase/mysqlConnector/sameUser.mjs +1 -0
- package/dist/legacy/firebase/transactionDBAsync.cjs +2 -0
- package/dist/legacy/firebase/transactionDBAsync.mjs +1 -0
- package/dist/legacy/get/countObj.cjs +3 -0
- package/dist/legacy/get/countObj.mjs +1 -0
- package/dist/legacy/get/decimalColor.cjs +3 -0
- package/dist/legacy/get/decimalColor.mjs +1 -0
- package/dist/legacy/get/objType.cjs +2 -0
- package/dist/legacy/get/objType.mjs +1 -0
- package/dist/legacy/get/pagination.cjs +3 -0
- package/dist/legacy/get/pagination.mjs +1 -0
- package/dist/legacy/get/queryUrlByName.cjs +2 -0
- package/dist/legacy/get/queryUrlByName.mjs +1 -0
- package/dist/legacy/get/queryUrlJSON.cjs +2 -0
- package/dist/legacy/get/queryUrlJSON.mjs +1 -0
- package/dist/legacy/get/super_string_filter.cjs +3 -0
- package/dist/legacy/get/super_string_filter.mjs +1 -0
- package/dist/legacy/get/versionCheck.cjs +2 -1
- package/dist/legacy/get/versionCheck.mjs +1 -0
- package/dist/legacy/http/HTTP-1.0.cjs +2 -0
- package/dist/legacy/http/HTTP-1.0.mjs +1 -0
- package/dist/legacy/http/auth.cjs +2 -0
- package/dist/legacy/http/auth.mjs +1 -0
- package/dist/legacy/http/check_domain.cjs +2 -0
- package/dist/legacy/http/check_domain.mjs +1 -0
- package/dist/legacy/http/csrfTokenAnalyze.cjs +2 -0
- package/dist/legacy/http/csrfTokenAnalyze.mjs +1 -0
- package/dist/legacy/http/domainValidator.cjs +3 -0
- package/dist/legacy/http/domainValidator.mjs +1 -0
- package/dist/legacy/http/errorsCallback.cjs +2 -0
- package/dist/legacy/http/errorsCallback.mjs +1 -0
- package/dist/legacy/http/fetch/json.cjs +3 -0
- package/dist/legacy/http/fetch/json.mjs +1 -0
- package/dist/legacy/http/fetch/text.cjs +3 -0
- package/dist/legacy/http/fetch/text.mjs +1 -0
- package/dist/legacy/http/fileCache.cjs +3 -0
- package/dist/legacy/http/fileCache.mjs +1 -0
- package/dist/legacy/http/getDomainURL.cjs +3 -0
- package/dist/legacy/http/getDomainURL.mjs +1 -0
- package/dist/legacy/http/userIP.cjs +3 -0
- package/dist/legacy/http/userIP.mjs +1 -0
- package/dist/legacy/index.cjs +3 -0
- package/dist/legacy/index.mjs +1 -0
- package/dist/legacy/libs/arraySortPositions.cjs +2 -0
- package/dist/legacy/libs/arraySortPositions.mjs +1 -0
- package/dist/legacy/libs/capitalize.cjs +2 -0
- package/dist/legacy/libs/capitalize.mjs +1 -0
- package/dist/legacy/libs/convertBytes.cjs +2 -0
- package/dist/legacy/libs/convertBytes.mjs +1 -0
- package/dist/legacy/libs/custom_module_loader.cjs +3 -0
- package/dist/legacy/libs/custom_module_loader.mjs +1 -0
- package/dist/legacy/libs/dice.cjs +2 -0
- package/dist/legacy/libs/dice.mjs +1 -0
- package/dist/legacy/libs/markdown.cjs +2 -0
- package/dist/legacy/libs/markdown.mjs +1 -0
- package/dist/legacy/libs/percentage.cjs +2 -0
- package/dist/legacy/libs/percentage.mjs +1 -0
- package/dist/legacy/libs/regex/getLetter.cjs +2 -0
- package/dist/legacy/libs/regex/getLetter.mjs +1 -0
- package/dist/legacy/libs/replaceAsync.cjs +3 -0
- package/dist/legacy/libs/replaceAsync.mjs +3 -0
- package/dist/legacy/libs/rule3.cjs +2 -0
- package/dist/legacy/libs/rule3.mjs +1 -0
- package/dist/legacy/libs/userLevel.cjs +9 -9
- package/dist/legacy/libs/userLevel.d.mts +39 -16
- package/dist/legacy/libs/userLevel.mjs +9 -9
- package/dist/legacy/momentjs/getAge.cjs +3 -0
- package/dist/legacy/momentjs/getAge.mjs +1 -0
- package/dist/legacy/momentjs/index.cjs +1 -1
- package/dist/legacy/momentjs/index.mjs +1 -0
- package/dist/legacy/momentjs/timeDuration.cjs +3 -0
- package/dist/legacy/momentjs/timeDuration.mjs +1 -0
- package/dist/legacy/socket.io/antiFlood/index.cjs +1 -1
- package/dist/legacy/socket.io/antiFlood/index.mjs +1 -0
- package/dist/legacy/socket.io/antiFlood/install.cjs +3 -0
- package/dist/legacy/socket.io/antiFlood/install.mjs +1 -0
- package/dist/legacy/socket.io/antiFlood/verify.cjs +3 -0
- package/dist/legacy/socket.io/antiFlood/verify.mjs +1 -0
- package/dist/legacy/socket.io/cookie-session.cjs +2 -0
- package/dist/legacy/socket.io/cookie-session.mjs +1 -0
- package/dist/legacy/socket.io/discord.cjs +3 -0
- package/dist/legacy/socket.io/discord.mjs +1 -0
- package/dist/legacy/socket.io/index.cjs +3 -0
- package/dist/legacy/socket.io/index.mjs +1 -0
- package/dist/v1/basics/clock.cjs +43 -13
- package/dist/v1/basics/clock.mjs +31 -13
- package/dist/v1/basics/index.cjs +27 -0
- package/dist/v1/basics/index.d.mts +17 -0
- package/dist/v1/basics/index.mjs +7 -0
- package/dist/v1/basics/objFilter.cjs +7 -1
- package/dist/v1/basics/objFilter.mjs +4 -0
- package/dist/v1/basics/simpleMath.cjs +1 -1
- package/dist/v1/basics/simpleMath.mjs +1 -1
- package/dist/v1/build/TinyCertCrypto.cjs +7 -0
- package/dist/v1/build/TinyCertCrypto.d.mts +2 -0
- package/dist/v1/build/TinyCertCrypto.mjs +2 -0
- package/dist/v1/build/TinyCrypto.cjs +7 -0
- package/dist/v1/build/TinyCrypto.d.mts +2 -0
- package/dist/v1/build/TinyCrypto.mjs +2 -0
- package/dist/v1/build/TinyLevelUp.cjs +7 -0
- package/dist/v1/build/TinyLevelUp.d.mts +2 -0
- package/dist/v1/build/TinyLevelUp.mjs +2 -0
- package/dist/v1/index.cjs +2 -0
- package/dist/v1/index.d.mts +2 -1
- package/dist/v1/index.mjs +2 -1
- package/dist/v1/libs/TinyCertCrypto.cjs +573 -0
- package/dist/v1/libs/TinyCertCrypto.d.mts +193 -0
- package/dist/v1/libs/TinyCertCrypto.mjs +481 -0
- package/dist/v1/libs/TinyCrypto.cjs +91 -45
- package/dist/v1/libs/TinyCrypto.d.mts +65 -26
- package/dist/v1/libs/TinyCrypto.mjs +64 -39
- package/docs/README.md +2 -0
- package/docs/libs/TinyCertCrypto.md +202 -0
- package/package.json +11 -6
package/dist/v1/basics/clock.cjs
CHANGED
|
@@ -11,7 +11,8 @@
|
|
|
11
11
|
function getTimeDuration(timeData = new Date(), durationType = 'asSeconds', now = null) {
|
|
12
12
|
if (timeData instanceof Date) {
|
|
13
13
|
const currentTime = now instanceof Date ? now : new Date();
|
|
14
|
-
|
|
14
|
+
/** @type {number} */
|
|
15
|
+
const diffMs = timeData.getTime() - currentTime.getTime();
|
|
15
16
|
|
|
16
17
|
switch (durationType) {
|
|
17
18
|
case 'asMilliseconds':
|
|
@@ -56,6 +57,17 @@ function formatCustomTimer(totalSeconds, level = 'seconds', format = '{time}') {
|
|
|
56
57
|
seconds: index >= 0,
|
|
57
58
|
};
|
|
58
59
|
|
|
60
|
+
/**
|
|
61
|
+
* @type {{
|
|
62
|
+
* years: number|NaN,
|
|
63
|
+
* months: number|NaN,
|
|
64
|
+
* days: number|NaN,
|
|
65
|
+
* hours: number|NaN,
|
|
66
|
+
* minutes: number|NaN,
|
|
67
|
+
* seconds: number|NaN,
|
|
68
|
+
* total: number|NaN
|
|
69
|
+
* }}
|
|
70
|
+
*/
|
|
59
71
|
const parts = {
|
|
60
72
|
years: include.years ? 0 : NaN,
|
|
61
73
|
months: include.months ? 0 : NaN,
|
|
@@ -76,8 +88,11 @@ function formatCustomTimer(totalSeconds, level = 'seconds', format = '{time}') {
|
|
|
76
88
|
// Years
|
|
77
89
|
if (include.years) {
|
|
78
90
|
while (
|
|
79
|
-
new Date(
|
|
80
|
-
|
|
91
|
+
new Date(
|
|
92
|
+
workingDate.getFullYear() + 1,
|
|
93
|
+
workingDate.getMonth(),
|
|
94
|
+
workingDate.getDate(),
|
|
95
|
+
).getTime() <= targetDate.getTime()
|
|
81
96
|
) {
|
|
82
97
|
workingDate.setFullYear(workingDate.getFullYear() + 1);
|
|
83
98
|
parts.years++;
|
|
@@ -87,8 +102,11 @@ function formatCustomTimer(totalSeconds, level = 'seconds', format = '{time}') {
|
|
|
87
102
|
// Months
|
|
88
103
|
if (include.months) {
|
|
89
104
|
while (
|
|
90
|
-
new Date(
|
|
91
|
-
|
|
105
|
+
new Date(
|
|
106
|
+
workingDate.getFullYear(),
|
|
107
|
+
workingDate.getMonth() + 1,
|
|
108
|
+
workingDate.getDate(),
|
|
109
|
+
).getTime() <= targetDate.getTime()
|
|
92
110
|
) {
|
|
93
111
|
workingDate.setMonth(workingDate.getMonth() + 1);
|
|
94
112
|
parts.months++;
|
|
@@ -98,15 +116,18 @@ function formatCustomTimer(totalSeconds, level = 'seconds', format = '{time}') {
|
|
|
98
116
|
// Days
|
|
99
117
|
if (include.days) {
|
|
100
118
|
while (
|
|
101
|
-
new Date(
|
|
102
|
-
|
|
119
|
+
new Date(
|
|
120
|
+
workingDate.getFullYear(),
|
|
121
|
+
workingDate.getMonth(),
|
|
122
|
+
workingDate.getDate() + 1,
|
|
123
|
+
).getTime() <= targetDate.getTime()
|
|
103
124
|
) {
|
|
104
125
|
workingDate.setDate(workingDate.getDate() + 1);
|
|
105
126
|
parts.days++;
|
|
106
127
|
}
|
|
107
128
|
}
|
|
108
129
|
|
|
109
|
-
remaining = Math.floor((targetDate - workingDate) / 1000);
|
|
130
|
+
remaining = Math.floor((targetDate.getTime() - workingDate.getTime()) / 1000);
|
|
110
131
|
}
|
|
111
132
|
|
|
112
133
|
if (include.hours) {
|
|
@@ -135,7 +156,16 @@ function formatCustomTimer(totalSeconds, level = 'seconds', format = '{time}') {
|
|
|
135
156
|
|
|
136
157
|
parts.total = +(totalMap[level] || 0).toFixed(2).replace(/\.00$/, '');
|
|
137
158
|
|
|
138
|
-
|
|
159
|
+
/**
|
|
160
|
+
* Pads a number to ensure it is at least two digits long, using leading zeros if necessary.
|
|
161
|
+
*
|
|
162
|
+
* @param {number|string} n - The number or string to pad.
|
|
163
|
+
* @returns {string} The padded string.
|
|
164
|
+
*/
|
|
165
|
+
const pad = (n) => {
|
|
166
|
+
const num = typeof n === 'string' ? parseInt(n) : n;
|
|
167
|
+
return Number.isNaN(num) ? 'NaN' : String(num).padStart(2, '0');
|
|
168
|
+
};
|
|
139
169
|
|
|
140
170
|
const timeString = [
|
|
141
171
|
include.hours ? pad(parts.hours) : null,
|
|
@@ -146,14 +176,14 @@ function formatCustomTimer(totalSeconds, level = 'seconds', format = '{time}') {
|
|
|
146
176
|
.join(':');
|
|
147
177
|
|
|
148
178
|
return format
|
|
149
|
-
.replace(/\{years\}/g, parts.years)
|
|
150
|
-
.replace(/\{months\}/g, parts.months)
|
|
151
|
-
.replace(/\{days\}/g, parts.days)
|
|
179
|
+
.replace(/\{years\}/g, String(parts.years))
|
|
180
|
+
.replace(/\{months\}/g, String(parts.months))
|
|
181
|
+
.replace(/\{days\}/g, String(parts.days))
|
|
152
182
|
.replace(/\{hours\}/g, pad(parts.hours))
|
|
153
183
|
.replace(/\{minutes\}/g, pad(parts.minutes))
|
|
154
184
|
.replace(/\{seconds\}/g, pad(parts.seconds))
|
|
155
185
|
.replace(/\{time\}/g, timeString)
|
|
156
|
-
.replace(/\{total\}/g, parts.total)
|
|
186
|
+
.replace(/\{total\}/g, String(parts.total))
|
|
157
187
|
.trim();
|
|
158
188
|
}
|
|
159
189
|
|
package/dist/v1/basics/clock.mjs
CHANGED
|
@@ -9,7 +9,8 @@
|
|
|
9
9
|
export function getTimeDuration(timeData = new Date(), durationType = 'asSeconds', now = null) {
|
|
10
10
|
if (timeData instanceof Date) {
|
|
11
11
|
const currentTime = now instanceof Date ? now : new Date();
|
|
12
|
-
|
|
12
|
+
/** @type {number} */
|
|
13
|
+
const diffMs = timeData.getTime() - currentTime.getTime();
|
|
13
14
|
switch (durationType) {
|
|
14
15
|
case 'asMilliseconds':
|
|
15
16
|
return diffMs;
|
|
@@ -48,6 +49,17 @@ export function formatCustomTimer(totalSeconds, level = 'seconds', format = '{ti
|
|
|
48
49
|
minutes: index >= 1,
|
|
49
50
|
seconds: index >= 0,
|
|
50
51
|
};
|
|
52
|
+
/**
|
|
53
|
+
* @type {{
|
|
54
|
+
* years: number|NaN,
|
|
55
|
+
* months: number|NaN,
|
|
56
|
+
* days: number|NaN,
|
|
57
|
+
* hours: number|NaN,
|
|
58
|
+
* minutes: number|NaN,
|
|
59
|
+
* seconds: number|NaN,
|
|
60
|
+
* total: number|NaN
|
|
61
|
+
* }}
|
|
62
|
+
*/
|
|
51
63
|
const parts = {
|
|
52
64
|
years: include.years ? 0 : NaN,
|
|
53
65
|
months: include.months ? 0 : NaN,
|
|
@@ -64,29 +76,26 @@ export function formatCustomTimer(totalSeconds, level = 'seconds', format = '{ti
|
|
|
64
76
|
const workingDate = new Date(baseDate);
|
|
65
77
|
// Years
|
|
66
78
|
if (include.years) {
|
|
67
|
-
while (new Date(workingDate.getFullYear() + 1, workingDate.getMonth(), workingDate.getDate()) <=
|
|
68
|
-
targetDate) {
|
|
79
|
+
while (new Date(workingDate.getFullYear() + 1, workingDate.getMonth(), workingDate.getDate()).getTime() <= targetDate.getTime()) {
|
|
69
80
|
workingDate.setFullYear(workingDate.getFullYear() + 1);
|
|
70
81
|
parts.years++;
|
|
71
82
|
}
|
|
72
83
|
}
|
|
73
84
|
// Months
|
|
74
85
|
if (include.months) {
|
|
75
|
-
while (new Date(workingDate.getFullYear(), workingDate.getMonth() + 1, workingDate.getDate()) <=
|
|
76
|
-
targetDate) {
|
|
86
|
+
while (new Date(workingDate.getFullYear(), workingDate.getMonth() + 1, workingDate.getDate()).getTime() <= targetDate.getTime()) {
|
|
77
87
|
workingDate.setMonth(workingDate.getMonth() + 1);
|
|
78
88
|
parts.months++;
|
|
79
89
|
}
|
|
80
90
|
}
|
|
81
91
|
// Days
|
|
82
92
|
if (include.days) {
|
|
83
|
-
while (new Date(workingDate.getFullYear(), workingDate.getMonth(), workingDate.getDate() + 1) <=
|
|
84
|
-
targetDate) {
|
|
93
|
+
while (new Date(workingDate.getFullYear(), workingDate.getMonth(), workingDate.getDate() + 1).getTime() <= targetDate.getTime()) {
|
|
85
94
|
workingDate.setDate(workingDate.getDate() + 1);
|
|
86
95
|
parts.days++;
|
|
87
96
|
}
|
|
88
97
|
}
|
|
89
|
-
remaining = Math.floor((targetDate - workingDate) / 1000);
|
|
98
|
+
remaining = Math.floor((targetDate.getTime() - workingDate.getTime()) / 1000);
|
|
90
99
|
}
|
|
91
100
|
if (include.hours) {
|
|
92
101
|
parts.hours = Math.floor(remaining / 3600);
|
|
@@ -109,7 +118,16 @@ export function formatCustomTimer(totalSeconds, level = 'seconds', format = '{ti
|
|
|
109
118
|
years: include.years ? parts.years + (parts.months || 0) / 12 + (parts.days || 0) / 365 : NaN,
|
|
110
119
|
};
|
|
111
120
|
parts.total = +(totalMap[level] || 0).toFixed(2).replace(/\.00$/, '');
|
|
112
|
-
|
|
121
|
+
/**
|
|
122
|
+
* Pads a number to ensure it is at least two digits long, using leading zeros if necessary.
|
|
123
|
+
*
|
|
124
|
+
* @param {number|string} n - The number or string to pad.
|
|
125
|
+
* @returns {string} The padded string.
|
|
126
|
+
*/
|
|
127
|
+
const pad = (n) => {
|
|
128
|
+
const num = typeof n === 'string' ? parseInt(n) : n;
|
|
129
|
+
return Number.isNaN(num) ? 'NaN' : String(num).padStart(2, '0');
|
|
130
|
+
};
|
|
113
131
|
const timeString = [
|
|
114
132
|
include.hours ? pad(parts.hours) : null,
|
|
115
133
|
include.minutes ? pad(parts.minutes) : null,
|
|
@@ -118,14 +136,14 @@ export function formatCustomTimer(totalSeconds, level = 'seconds', format = '{ti
|
|
|
118
136
|
.filter((v) => v !== null)
|
|
119
137
|
.join(':');
|
|
120
138
|
return format
|
|
121
|
-
.replace(/\{years\}/g, parts.years)
|
|
122
|
-
.replace(/\{months\}/g, parts.months)
|
|
123
|
-
.replace(/\{days\}/g, parts.days)
|
|
139
|
+
.replace(/\{years\}/g, String(parts.years))
|
|
140
|
+
.replace(/\{months\}/g, String(parts.months))
|
|
141
|
+
.replace(/\{days\}/g, String(parts.days))
|
|
124
142
|
.replace(/\{hours\}/g, pad(parts.hours))
|
|
125
143
|
.replace(/\{minutes\}/g, pad(parts.minutes))
|
|
126
144
|
.replace(/\{seconds\}/g, pad(parts.seconds))
|
|
127
145
|
.replace(/\{time\}/g, timeString)
|
|
128
|
-
.replace(/\{total\}/g, parts.total)
|
|
146
|
+
.replace(/\{total\}/g, String(parts.total))
|
|
129
147
|
.trim();
|
|
130
148
|
}
|
|
131
149
|
/**
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var replaceAsync = require('../../legacy/libs/replaceAsync.cjs');
|
|
4
|
+
var array = require('./array.cjs');
|
|
5
|
+
var clock = require('./clock.cjs');
|
|
6
|
+
var objFilter = require('./objFilter.cjs');
|
|
7
|
+
var simpleMath = require('./simpleMath.cjs');
|
|
8
|
+
var text = require('./text.cjs');
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
exports.asyncReplace = replaceAsync;
|
|
13
|
+
exports.shuffleArray = array.shuffleArray;
|
|
14
|
+
exports.formatCustomTimer = clock.formatCustomTimer;
|
|
15
|
+
exports.formatDayTimer = clock.formatDayTimer;
|
|
16
|
+
exports.formatTimer = clock.formatTimer;
|
|
17
|
+
exports.getTimeDuration = clock.getTimeDuration;
|
|
18
|
+
exports.cloneObjTypeOrder = objFilter.cloneObjTypeOrder;
|
|
19
|
+
exports.countObj = objFilter.countObj;
|
|
20
|
+
exports.extendObjType = objFilter.extendObjType;
|
|
21
|
+
exports.objType = objFilter.objType;
|
|
22
|
+
exports.reorderObjTypeOrder = objFilter.reorderObjTypeOrder;
|
|
23
|
+
exports.getAge = simpleMath.getAge;
|
|
24
|
+
exports.getSimplePerc = simpleMath.getSimplePerc;
|
|
25
|
+
exports.ruleOfThree = simpleMath.ruleOfThree;
|
|
26
|
+
exports.toTitleCase = text.toTitleCase;
|
|
27
|
+
exports.toTitleCaseLowerFirst = text.toTitleCaseLowerFirst;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { extendObjType } from './objFilter.mjs';
|
|
2
|
+
import { reorderObjTypeOrder } from './objFilter.mjs';
|
|
3
|
+
import { cloneObjTypeOrder } from './objFilter.mjs';
|
|
4
|
+
import { countObj } from './objFilter.mjs';
|
|
5
|
+
import { objType } from './objFilter.mjs';
|
|
6
|
+
import { ruleOfThree } from './simpleMath.mjs';
|
|
7
|
+
import { getSimplePerc } from './simpleMath.mjs';
|
|
8
|
+
import asyncReplace from '../../legacy/libs/replaceAsync.mjs';
|
|
9
|
+
import { getAge } from './simpleMath.mjs';
|
|
10
|
+
import { formatCustomTimer } from './clock.mjs';
|
|
11
|
+
import { formatDayTimer } from './clock.mjs';
|
|
12
|
+
import { formatTimer } from './clock.mjs';
|
|
13
|
+
import { getTimeDuration } from './clock.mjs';
|
|
14
|
+
import { shuffleArray } from './array.mjs';
|
|
15
|
+
import { toTitleCase } from './text.mjs';
|
|
16
|
+
import { toTitleCaseLowerFirst } from './text.mjs';
|
|
17
|
+
export { extendObjType, reorderObjTypeOrder, cloneObjTypeOrder, countObj, objType, ruleOfThree, getSimplePerc, asyncReplace, getAge, formatCustomTimer, formatDayTimer, formatTimer, getTimeDuration, shuffleArray, toTitleCase, toTitleCaseLowerFirst };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import asyncReplace from '../../legacy/libs/replaceAsync.mjs';
|
|
2
|
+
import { shuffleArray } from './array.mjs';
|
|
3
|
+
import { formatCustomTimer, formatDayTimer, formatTimer, getTimeDuration } from './clock.mjs';
|
|
4
|
+
import { countObj, extendObjType, reorderObjTypeOrder, cloneObjTypeOrder, objType, } from './objFilter.mjs';
|
|
5
|
+
import { getAge, getSimplePerc, ruleOfThree } from './simpleMath.mjs';
|
|
6
|
+
import { toTitleCase, toTitleCaseLowerFirst } from './text.mjs';
|
|
7
|
+
export { extendObjType, reorderObjTypeOrder, cloneObjTypeOrder, countObj, objType, ruleOfThree, getSimplePerc, asyncReplace, getAge, formatCustomTimer, formatDayTimer, formatTimer, getTimeDuration, shuffleArray, toTitleCase, toTitleCaseLowerFirst, };
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
var buffer = require('buffer');
|
|
4
|
+
|
|
3
5
|
/**
|
|
4
6
|
* An object containing type validation functions and their evaluation order.
|
|
5
7
|
*
|
|
@@ -70,7 +72,10 @@ const typeValidator = {
|
|
|
70
72
|
promise: (val) => val instanceof Promise,
|
|
71
73
|
|
|
72
74
|
/** Checks if the value is a Buffer. */
|
|
73
|
-
buffer: (val) => typeof Buffer !== 'undefined' && Buffer.isBuffer(val),
|
|
75
|
+
buffer: (val) => typeof buffer.Buffer !== 'undefined' && buffer.Buffer.isBuffer(val),
|
|
76
|
+
|
|
77
|
+
/** Checks if the value is a File. */
|
|
78
|
+
file: (val) => typeof File !== 'undefined' && val instanceof File,
|
|
74
79
|
|
|
75
80
|
/** Checks if the value is a Html Element. */
|
|
76
81
|
htmlelement: (val) => typeof HTMLElement !== 'undefined' && val instanceof HTMLElement,
|
|
@@ -91,6 +96,7 @@ const typeValidator = {
|
|
|
91
96
|
'function',
|
|
92
97
|
'array',
|
|
93
98
|
'buffer',
|
|
99
|
+
'file',
|
|
94
100
|
'date',
|
|
95
101
|
'regexp',
|
|
96
102
|
'map',
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { Buffer } from 'buffer';
|
|
1
2
|
/**
|
|
2
3
|
* An object containing type validation functions and their evaluation order.
|
|
3
4
|
*
|
|
@@ -52,6 +53,8 @@ const typeValidator = {
|
|
|
52
53
|
promise: (val) => val instanceof Promise,
|
|
53
54
|
/** Checks if the value is a Buffer. */
|
|
54
55
|
buffer: (val) => typeof Buffer !== 'undefined' && Buffer.isBuffer(val),
|
|
56
|
+
/** Checks if the value is a File. */
|
|
57
|
+
file: (val) => typeof File !== 'undefined' && val instanceof File,
|
|
55
58
|
/** Checks if the value is a Html Element. */
|
|
56
59
|
htmlelement: (val) => typeof HTMLElement !== 'undefined' && val instanceof HTMLElement,
|
|
57
60
|
/** Checks if the value is a non-null plain object or instance of a class. */
|
|
@@ -69,6 +72,7 @@ const typeValidator = {
|
|
|
69
72
|
'function',
|
|
70
73
|
'array',
|
|
71
74
|
'buffer',
|
|
75
|
+
'file',
|
|
72
76
|
'date',
|
|
73
77
|
'regexp',
|
|
74
78
|
'map',
|
|
@@ -62,7 +62,7 @@ function getSimplePerc(price, percentage) {
|
|
|
62
62
|
function getAge(timeData = 0, now = null) {
|
|
63
63
|
if (typeof timeData !== 'undefined' && timeData !== null && timeData !== 0) {
|
|
64
64
|
const birthDate = new Date(timeData);
|
|
65
|
-
if (isNaN(birthDate)) return null;
|
|
65
|
+
if (Number.isNaN(birthDate.getTime())) return null;
|
|
66
66
|
|
|
67
67
|
const currentDate = now instanceof Date ? now : new Date();
|
|
68
68
|
|
|
@@ -58,7 +58,7 @@ export function getSimplePerc(price, percentage) {
|
|
|
58
58
|
export function getAge(timeData = 0, now = null) {
|
|
59
59
|
if (typeof timeData !== 'undefined' && timeData !== null && timeData !== 0) {
|
|
60
60
|
const birthDate = new Date(timeData);
|
|
61
|
-
if (isNaN(birthDate))
|
|
61
|
+
if (Number.isNaN(birthDate.getTime()))
|
|
62
62
|
return null;
|
|
63
63
|
const currentDate = now instanceof Date ? now : new Date();
|
|
64
64
|
let age = currentDate.getFullYear() - birthDate.getFullYear();
|
package/dist/v1/index.cjs
CHANGED
|
@@ -8,6 +8,7 @@ var objFilter = require('./basics/objFilter.cjs');
|
|
|
8
8
|
var simpleMath = require('./basics/simpleMath.cjs');
|
|
9
9
|
var text = require('./basics/text.cjs');
|
|
10
10
|
var TinyCrypto = require('./libs/TinyCrypto.cjs');
|
|
11
|
+
var TinyCertCrypto = require('./libs/TinyCertCrypto.cjs');
|
|
11
12
|
|
|
12
13
|
|
|
13
14
|
|
|
@@ -29,3 +30,4 @@ exports.ruleOfThree = simpleMath.ruleOfThree;
|
|
|
29
30
|
exports.toTitleCase = text.toTitleCase;
|
|
30
31
|
exports.toTitleCaseLowerFirst = text.toTitleCaseLowerFirst;
|
|
31
32
|
exports.TinyCrypto = TinyCrypto;
|
|
33
|
+
exports.TinyCertCrypto = TinyCertCrypto;
|
package/dist/v1/index.d.mts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import TinyCrypto from './libs/TinyCrypto.mjs';
|
|
2
|
+
import TinyCertCrypto from './libs/TinyCertCrypto.mjs';
|
|
2
3
|
import TinyLevelUp from '../legacy/libs/userLevel.mjs';
|
|
3
4
|
import { extendObjType } from './basics/objFilter.mjs';
|
|
4
5
|
import { reorderObjTypeOrder } from './basics/objFilter.mjs';
|
|
@@ -16,4 +17,4 @@ import { getTimeDuration } from './basics/clock.mjs';
|
|
|
16
17
|
import { shuffleArray } from './basics/array.mjs';
|
|
17
18
|
import { toTitleCase } from './basics/text.mjs';
|
|
18
19
|
import { toTitleCaseLowerFirst } from './basics/text.mjs';
|
|
19
|
-
export { TinyCrypto, TinyLevelUp, extendObjType, reorderObjTypeOrder, cloneObjTypeOrder, countObj, objType, ruleOfThree, getSimplePerc, asyncReplace, getAge, formatCustomTimer, formatDayTimer, formatTimer, getTimeDuration, shuffleArray, toTitleCase, toTitleCaseLowerFirst };
|
|
20
|
+
export { TinyCrypto, TinyCertCrypto, TinyLevelUp, extendObjType, reorderObjTypeOrder, cloneObjTypeOrder, countObj, objType, ruleOfThree, getSimplePerc, asyncReplace, getAge, formatCustomTimer, formatDayTimer, formatTimer, getTimeDuration, shuffleArray, toTitleCase, toTitleCaseLowerFirst };
|
package/dist/v1/index.mjs
CHANGED
|
@@ -6,4 +6,5 @@ import { countObj, extendObjType, reorderObjTypeOrder, cloneObjTypeOrder, objTyp
|
|
|
6
6
|
import { getAge, getSimplePerc, ruleOfThree } from './basics/simpleMath.mjs';
|
|
7
7
|
import { toTitleCase, toTitleCaseLowerFirst } from './basics/text.mjs';
|
|
8
8
|
import TinyCrypto from './libs/TinyCrypto.mjs';
|
|
9
|
-
|
|
9
|
+
import TinyCertCrypto from './libs/TinyCertCrypto.mjs';
|
|
10
|
+
export { TinyCrypto, TinyCertCrypto, TinyLevelUp, extendObjType, reorderObjTypeOrder, cloneObjTypeOrder, countObj, objType, ruleOfThree, getSimplePerc, asyncReplace, getAge, formatCustomTimer, formatDayTimer, formatTimer, getTimeDuration, shuffleArray, toTitleCase, toTitleCaseLowerFirst, };
|