tiny-essentials 1.20.3 → 1.21.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 +13 -11
- package/dist/_/numbers.cjs +136 -0
- package/dist/_/numbers.d.mts +24 -0
- package/dist/_/numbers.mjs +102 -0
- package/dist/v1/TinyAdvancedRaffle.min.js +1 -0
- package/dist/v1/TinyArrayPaginator.min.js +1 -0
- package/dist/v1/TinyBasicsEs.min.js +1 -1
- package/dist/v1/TinyCookieConsent.min.js +1 -0
- package/dist/v1/TinyDayNightCycle.min.js +1 -0
- package/dist/v1/TinyEssentials.min.js +1 -1
- package/dist/v1/TinyGamepad.min.js +1 -0
- package/dist/v1/TinyI18.min.js +1 -0
- package/dist/v1/TinyInventory.min.js +1 -0
- package/dist/v1/TinyInventoryTrader.min.js +1 -0
- package/dist/v1/TinyLocalStorage.min.js +1 -1
- package/dist/v1/TinyNeedBar.min.js +1 -0
- package/dist/v1/TinyRateLimiter.min.js +1 -1
- package/dist/v1/TinySmartScroller.min.js +1 -1
- package/dist/v1/TinyToastNotify.min.js +1 -1
- package/dist/v1/TinyUploadClicker.min.js +1 -1
- package/dist/v1/basics/array.cjs +21 -0
- package/dist/v1/basics/array.d.mts +8 -0
- package/dist/v1/basics/array.mjs +18 -0
- package/dist/v1/basics/clock.cjs +127 -11
- package/dist/v1/basics/clock.d.mts +26 -0
- package/dist/v1/basics/clock.mjs +96 -1
- package/dist/v1/basics/index.cjs +2 -8
- package/dist/v1/basics/index.d.mts +3 -8
- package/dist/v1/basics/index.mjs +2 -3
- package/dist/v1/basics/simpleMath.cjs +46 -0
- package/dist/v1/basics/simpleMath.d.mts +27 -0
- package/dist/v1/basics/simpleMath.mjs +42 -0
- package/dist/v1/build/TinyAdvancedRaffle.cjs +7 -0
- package/dist/v1/build/TinyAdvancedRaffle.d.mts +3 -0
- package/dist/v1/build/TinyAdvancedRaffle.mjs +2 -0
- package/dist/v1/build/TinyArrayPaginator.cjs +7 -0
- package/dist/v1/build/TinyArrayPaginator.d.mts +3 -0
- package/dist/v1/build/TinyArrayPaginator.mjs +2 -0
- package/dist/v1/build/TinyCookieConsent.cjs +7 -0
- package/dist/v1/build/TinyCookieConsent.d.mts +3 -0
- package/dist/v1/build/TinyCookieConsent.mjs +2 -0
- package/dist/v1/build/TinyDayNightCycle.cjs +7 -0
- package/dist/v1/build/TinyDayNightCycle.d.mts +3 -0
- package/dist/v1/build/TinyDayNightCycle.mjs +2 -0
- package/dist/v1/build/TinyGamepad.cjs +7 -0
- package/dist/v1/build/TinyGamepad.d.mts +3 -0
- package/dist/v1/build/TinyGamepad.mjs +2 -0
- package/dist/v1/build/TinyI18.cjs +7 -0
- package/dist/v1/build/TinyI18.d.mts +3 -0
- package/dist/v1/build/TinyI18.mjs +2 -0
- package/dist/v1/build/TinyInventory.cjs +7 -0
- package/dist/v1/build/TinyInventory.d.mts +3 -0
- package/dist/v1/build/TinyInventory.mjs +2 -0
- package/dist/v1/build/TinyInventoryTrader.cjs +7 -0
- package/dist/v1/build/TinyInventoryTrader.d.mts +3 -0
- package/dist/v1/build/TinyInventoryTrader.mjs +2 -0
- package/dist/v1/build/TinyNeedBar.cjs +7 -0
- package/dist/v1/build/TinyNeedBar.d.mts +3 -0
- package/dist/v1/build/TinyNeedBar.mjs +2 -0
- package/dist/v1/css/TinyCookieConsent.min.css +1 -0
- package/dist/v1/index.cjs +20 -8
- package/dist/v1/index.d.mts +12 -8
- package/dist/v1/index.mjs +11 -3
- package/dist/v1/libs/TinyAdvancedRaffle.cjs +1654 -0
- package/dist/v1/libs/TinyAdvancedRaffle.d.mts +851 -0
- package/dist/v1/libs/TinyAdvancedRaffle.mjs +1477 -0
- package/dist/v1/libs/TinyArrayPaginator.cjs +132 -0
- package/dist/v1/libs/TinyArrayPaginator.d.mts +78 -0
- package/dist/v1/libs/TinyArrayPaginator.mjs +119 -0
- package/dist/v1/libs/TinyCookieConsent.cjs +278 -0
- package/dist/v1/libs/TinyCookieConsent.d.mts +142 -0
- package/dist/v1/libs/TinyCookieConsent.mjs +248 -0
- package/dist/v1/libs/TinyDayNightCycle.cjs +1389 -0
- package/dist/v1/libs/TinyDayNightCycle.d.mts +673 -0
- package/dist/v1/libs/TinyDayNightCycle.mjs +1232 -0
- package/dist/v1/libs/TinyGamepad.cjs +2690 -0
- package/dist/v1/libs/TinyGamepad.d.mts +1286 -0
- package/dist/v1/libs/TinyGamepad.mjs +2386 -0
- package/dist/v1/libs/TinyHtml.d.mts +2 -2
- package/dist/v1/libs/TinyI18.cjs +946 -0
- package/dist/v1/libs/TinyI18.d.mts +418 -0
- package/dist/v1/libs/TinyI18.mjs +873 -0
- package/dist/v1/libs/TinyInventory.cjs +1788 -0
- package/dist/v1/libs/TinyInventory.d.mts +871 -0
- package/dist/v1/libs/TinyInventory.mjs +1650 -0
- package/dist/v1/libs/TinyInventoryTrader.cjs +242 -0
- package/dist/v1/libs/TinyInventoryTrader.d.mts +95 -0
- package/dist/v1/libs/TinyInventoryTrader.mjs +212 -0
- package/dist/v1/libs/TinyLocalStorage.cjs +14 -1
- package/dist/v1/libs/TinyLocalStorage.mjs +8 -1
- package/dist/v1/libs/TinyNeedBar.cjs +272 -0
- package/dist/v1/libs/TinyNeedBar.d.mts +223 -0
- package/dist/v1/libs/TinyNeedBar.mjs +241 -0
- package/dist/v1/libs/TinyRateLimiter.cjs +0 -13
- package/dist/v1/libs/TinyRateLimiter.d.mts +0 -8
- package/dist/v1/libs/TinyRateLimiter.mjs +0 -12
- package/dist/v1/libs/TinySmartScroller.cjs +0 -51
- package/dist/v1/libs/TinySmartScroller.d.mts +0 -36
- package/dist/v1/libs/TinySmartScroller.mjs +0 -46
- package/dist/v1/libs/TinyToastNotify.cjs +2 -2
- package/dist/v1/libs/TinyToastNotify.mjs +2 -2
- package/dist/v1/libs/TinyUploadClicker.cjs +1 -1
- package/docs/v1/Ai-Tips.md +51 -0
- package/docs/v1/Personal-Ai-Prompts(portuguese).md +134 -0
- package/docs/v1/Personal-Ai-Prompts.md +113 -0
- package/docs/v1/README.md +24 -0
- package/docs/v1/basics/array.md +17 -0
- package/docs/v1/basics/clock.md +51 -11
- package/docs/v1/basics/simpleMath.md +73 -0
- package/docs/v1/libs/TinyAdvancedRaffle.md +674 -0
- package/docs/v1/libs/TinyArrayPaginator.md +150 -0
- package/docs/v1/libs/TinyCookieConsent.md +152 -0
- package/docs/v1/libs/TinyDayNightCycle.md +711 -0
- package/docs/v1/libs/TinyGamepad.md +980 -0
- package/docs/v1/libs/TinyI18.md +515 -0
- package/docs/v1/libs/TinyInventory.md +777 -0
- package/docs/v1/libs/TinyInventoryTrader.md +114 -0
- package/docs/v1/libs/TinyNeedBar.md +226 -0
- package/package.json +7 -5
- package/dist/v1/basics/html_deprecated.cjs +0 -124
- package/dist/v1/basics/html_deprecated.d.mts +0 -40
- package/dist/v1/basics/html_deprecated.mjs +0 -97
- package/dist/v1/css/TinyDraggerExample.css +0 -21
- package/dist/v1/css/TinyNotify.css +0 -350
- package/dist/v1/css/aiMarker.css +0 -4
- package/docs/v1/basics/html_deprecated.md +0 -127
package/dist/v1/basics/clock.cjs
CHANGED
|
@@ -144,17 +144,7 @@ function formatCustomTimer(totalSeconds, level = 'seconds', format = '{time}') {
|
|
|
144
144
|
parts.seconds = remaining;
|
|
145
145
|
}
|
|
146
146
|
|
|
147
|
-
|
|
148
|
-
const totalMap = {
|
|
149
|
-
seconds: include.seconds ? totalSeconds : NaN,
|
|
150
|
-
minutes: include.minutes ? totalSeconds / 60 : NaN,
|
|
151
|
-
hours: include.hours ? totalSeconds / 3600 : NaN,
|
|
152
|
-
days: include.days ? totalSeconds / 86400 : NaN,
|
|
153
|
-
months: include.months ? parts.years * 12 + parts.months + (parts.days || 0) / 30 : NaN,
|
|
154
|
-
years: include.years ? parts.years + (parts.months || 0) / 12 + (parts.days || 0) / 365 : NaN,
|
|
155
|
-
};
|
|
156
|
-
|
|
157
|
-
parts.total = +(totalMap[level] || 0).toFixed(2).replace(/\.00$/, '');
|
|
147
|
+
parts.total = +totalSeconds.toFixed(2).replace(/\.00$/, '');
|
|
158
148
|
|
|
159
149
|
/**
|
|
160
150
|
* Pads a number to ensure it is at least two digits long, using leading zeros if necessary.
|
|
@@ -211,6 +201,132 @@ function formatDayTimer(seconds) {
|
|
|
211
201
|
return formatCustomTimer(seconds, 'days', '{days}d {hours}:{minutes}:{seconds}');
|
|
212
202
|
}
|
|
213
203
|
|
|
204
|
+
/**
|
|
205
|
+
* Breaks down a duration in milliseconds into its time components.
|
|
206
|
+
*
|
|
207
|
+
* @param {number} totalMs - The total duration in milliseconds.
|
|
208
|
+
* @param {'milliseconds'|'seconds'|'minutes'|'hours'|'days'|'months'|'years'} [level='milliseconds'] - The highest level to calculate and display.
|
|
209
|
+
* @returns {{
|
|
210
|
+
* years: number|NaN,
|
|
211
|
+
* months: number|NaN,
|
|
212
|
+
* days: number|NaN,
|
|
213
|
+
* hours: number|NaN,
|
|
214
|
+
* minutes: number|NaN,
|
|
215
|
+
* seconds: number|NaN,
|
|
216
|
+
* milliseconds: number|NaN,
|
|
217
|
+
* total: number|NaN
|
|
218
|
+
* }}
|
|
219
|
+
*/
|
|
220
|
+
function breakdownDuration(totalMs, level = 'milliseconds') {
|
|
221
|
+
totalMs = Math.max(0, Math.floor(totalMs));
|
|
222
|
+
|
|
223
|
+
const levels = ['milliseconds', 'seconds', 'minutes', 'hours', 'days', 'months', 'years'];
|
|
224
|
+
const index = levels.indexOf(level);
|
|
225
|
+
|
|
226
|
+
const include = {
|
|
227
|
+
years: index >= 6,
|
|
228
|
+
months: index >= 5,
|
|
229
|
+
days: index >= 4,
|
|
230
|
+
hours: index >= 3,
|
|
231
|
+
minutes: index >= 2,
|
|
232
|
+
seconds: index >= 1,
|
|
233
|
+
milliseconds: index >= 0,
|
|
234
|
+
};
|
|
235
|
+
|
|
236
|
+
const parts = {
|
|
237
|
+
years: include.years ? 0 : NaN,
|
|
238
|
+
months: include.months ? 0 : NaN,
|
|
239
|
+
days: include.days ? 0 : NaN,
|
|
240
|
+
hours: include.hours ? 0 : NaN,
|
|
241
|
+
minutes: include.minutes ? 0 : NaN,
|
|
242
|
+
seconds: include.seconds ? 0 : NaN,
|
|
243
|
+
milliseconds: include.milliseconds ? 0 : NaN,
|
|
244
|
+
total: NaN,
|
|
245
|
+
};
|
|
246
|
+
|
|
247
|
+
let remaining = totalMs;
|
|
248
|
+
|
|
249
|
+
if (include.years || include.months || include.days) {
|
|
250
|
+
const baseDate = new Date(1980, 0, 1);
|
|
251
|
+
const targetDate = new Date(baseDate.getTime() + remaining);
|
|
252
|
+
const workingDate = new Date(baseDate);
|
|
253
|
+
|
|
254
|
+
// Years
|
|
255
|
+
if (include.years) {
|
|
256
|
+
while (
|
|
257
|
+
new Date(
|
|
258
|
+
workingDate.getFullYear() + 1,
|
|
259
|
+
workingDate.getMonth(),
|
|
260
|
+
workingDate.getDate(),
|
|
261
|
+
).getTime() <= targetDate.getTime()
|
|
262
|
+
) {
|
|
263
|
+
workingDate.setFullYear(workingDate.getFullYear() + 1);
|
|
264
|
+
parts.years++;
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
// Months
|
|
269
|
+
if (include.months) {
|
|
270
|
+
while (
|
|
271
|
+
new Date(
|
|
272
|
+
workingDate.getFullYear(),
|
|
273
|
+
workingDate.getMonth() + 1,
|
|
274
|
+
workingDate.getDate(),
|
|
275
|
+
).getTime() <= targetDate.getTime()
|
|
276
|
+
) {
|
|
277
|
+
workingDate.setMonth(workingDate.getMonth() + 1);
|
|
278
|
+
parts.months++;
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
// Days
|
|
283
|
+
if (include.days) {
|
|
284
|
+
while (
|
|
285
|
+
new Date(
|
|
286
|
+
workingDate.getFullYear(),
|
|
287
|
+
workingDate.getMonth(),
|
|
288
|
+
workingDate.getDate() + 1,
|
|
289
|
+
).getTime() <= targetDate.getTime()
|
|
290
|
+
) {
|
|
291
|
+
workingDate.setDate(workingDate.getDate() + 1);
|
|
292
|
+
parts.days++;
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
remaining = targetDate.getTime() - workingDate.getTime();
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
if (include.hours) {
|
|
300
|
+
parts.hours = Math.floor(remaining / 3600000);
|
|
301
|
+
remaining %= 3600000;
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
if (include.minutes) {
|
|
305
|
+
parts.minutes = Math.floor(remaining / 60000);
|
|
306
|
+
remaining %= 60000;
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
if (include.seconds) {
|
|
310
|
+
parts.seconds = Math.floor(remaining / 1000);
|
|
311
|
+
remaining %= 1000;
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
if (include.milliseconds) {
|
|
315
|
+
parts.milliseconds = remaining;
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
// Totals
|
|
319
|
+
({
|
|
320
|
+
months: include.months ? parts.years * 12 + parts.months + (parts.days || 0) / 30 : NaN,
|
|
321
|
+
years: include.years ? parts.years + (parts.months || 0) / 12 + (parts.days || 0) / 365 : NaN,
|
|
322
|
+
});
|
|
323
|
+
|
|
324
|
+
parts.total = +totalMs;
|
|
325
|
+
|
|
326
|
+
return parts;
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
exports.breakdownDuration = breakdownDuration;
|
|
214
330
|
exports.formatCustomTimer = formatCustomTimer;
|
|
215
331
|
exports.formatDayTimer = formatDayTimer;
|
|
216
332
|
exports.formatTimer = formatTimer;
|
|
@@ -35,4 +35,30 @@ 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
|
+
/**
|
|
39
|
+
* Breaks down a duration in milliseconds into its time components.
|
|
40
|
+
*
|
|
41
|
+
* @param {number} totalMs - The total duration in milliseconds.
|
|
42
|
+
* @param {'milliseconds'|'seconds'|'minutes'|'hours'|'days'|'months'|'years'} [level='milliseconds'] - The highest level to calculate and display.
|
|
43
|
+
* @returns {{
|
|
44
|
+
* years: number|NaN,
|
|
45
|
+
* months: number|NaN,
|
|
46
|
+
* days: number|NaN,
|
|
47
|
+
* hours: number|NaN,
|
|
48
|
+
* minutes: number|NaN,
|
|
49
|
+
* seconds: number|NaN,
|
|
50
|
+
* milliseconds: number|NaN,
|
|
51
|
+
* total: number|NaN
|
|
52
|
+
* }}
|
|
53
|
+
*/
|
|
54
|
+
export function breakdownDuration(totalMs: number, level?: "milliseconds" | "seconds" | "minutes" | "hours" | "days" | "months" | "years"): {
|
|
55
|
+
years: number | number;
|
|
56
|
+
months: number | number;
|
|
57
|
+
days: number | number;
|
|
58
|
+
hours: number | number;
|
|
59
|
+
minutes: number | number;
|
|
60
|
+
seconds: number | number;
|
|
61
|
+
milliseconds: number | number;
|
|
62
|
+
total: number | number;
|
|
63
|
+
};
|
|
38
64
|
//# sourceMappingURL=clock.d.mts.map
|
package/dist/v1/basics/clock.mjs
CHANGED
|
@@ -117,7 +117,7 @@ export function formatCustomTimer(totalSeconds, level = 'seconds', format = '{ti
|
|
|
117
117
|
months: include.months ? parts.years * 12 + parts.months + (parts.days || 0) / 30 : NaN,
|
|
118
118
|
years: include.years ? parts.years + (parts.months || 0) / 12 + (parts.days || 0) / 365 : NaN,
|
|
119
119
|
};
|
|
120
|
-
parts.total = +
|
|
120
|
+
parts.total = +totalSeconds.toFixed(2).replace(/\.00$/, '');
|
|
121
121
|
/**
|
|
122
122
|
* Pads a number to ensure it is at least two digits long, using leading zeros if necessary.
|
|
123
123
|
*
|
|
@@ -168,3 +168,98 @@ export function formatTimer(seconds) {
|
|
|
168
168
|
export function formatDayTimer(seconds) {
|
|
169
169
|
return formatCustomTimer(seconds, 'days', '{days}d {hours}:{minutes}:{seconds}');
|
|
170
170
|
}
|
|
171
|
+
/**
|
|
172
|
+
* Breaks down a duration in milliseconds into its time components.
|
|
173
|
+
*
|
|
174
|
+
* @param {number} totalMs - The total duration in milliseconds.
|
|
175
|
+
* @param {'milliseconds'|'seconds'|'minutes'|'hours'|'days'|'months'|'years'} [level='milliseconds'] - The highest level to calculate and display.
|
|
176
|
+
* @returns {{
|
|
177
|
+
* years: number|NaN,
|
|
178
|
+
* months: number|NaN,
|
|
179
|
+
* days: number|NaN,
|
|
180
|
+
* hours: number|NaN,
|
|
181
|
+
* minutes: number|NaN,
|
|
182
|
+
* seconds: number|NaN,
|
|
183
|
+
* milliseconds: number|NaN,
|
|
184
|
+
* total: number|NaN
|
|
185
|
+
* }}
|
|
186
|
+
*/
|
|
187
|
+
export function breakdownDuration(totalMs, level = 'milliseconds') {
|
|
188
|
+
totalMs = Math.max(0, Math.floor(totalMs));
|
|
189
|
+
const levels = ['milliseconds', 'seconds', 'minutes', 'hours', 'days', 'months', 'years'];
|
|
190
|
+
const index = levels.indexOf(level);
|
|
191
|
+
const include = {
|
|
192
|
+
years: index >= 6,
|
|
193
|
+
months: index >= 5,
|
|
194
|
+
days: index >= 4,
|
|
195
|
+
hours: index >= 3,
|
|
196
|
+
minutes: index >= 2,
|
|
197
|
+
seconds: index >= 1,
|
|
198
|
+
milliseconds: index >= 0,
|
|
199
|
+
};
|
|
200
|
+
const parts = {
|
|
201
|
+
years: include.years ? 0 : NaN,
|
|
202
|
+
months: include.months ? 0 : NaN,
|
|
203
|
+
days: include.days ? 0 : NaN,
|
|
204
|
+
hours: include.hours ? 0 : NaN,
|
|
205
|
+
minutes: include.minutes ? 0 : NaN,
|
|
206
|
+
seconds: include.seconds ? 0 : NaN,
|
|
207
|
+
milliseconds: include.milliseconds ? 0 : NaN,
|
|
208
|
+
total: NaN,
|
|
209
|
+
};
|
|
210
|
+
let remaining = totalMs;
|
|
211
|
+
if (include.years || include.months || include.days) {
|
|
212
|
+
const baseDate = new Date(1980, 0, 1);
|
|
213
|
+
const targetDate = new Date(baseDate.getTime() + remaining);
|
|
214
|
+
const workingDate = new Date(baseDate);
|
|
215
|
+
// Years
|
|
216
|
+
if (include.years) {
|
|
217
|
+
while (new Date(workingDate.getFullYear() + 1, workingDate.getMonth(), workingDate.getDate()).getTime() <= targetDate.getTime()) {
|
|
218
|
+
workingDate.setFullYear(workingDate.getFullYear() + 1);
|
|
219
|
+
parts.years++;
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
// Months
|
|
223
|
+
if (include.months) {
|
|
224
|
+
while (new Date(workingDate.getFullYear(), workingDate.getMonth() + 1, workingDate.getDate()).getTime() <= targetDate.getTime()) {
|
|
225
|
+
workingDate.setMonth(workingDate.getMonth() + 1);
|
|
226
|
+
parts.months++;
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
// Days
|
|
230
|
+
if (include.days) {
|
|
231
|
+
while (new Date(workingDate.getFullYear(), workingDate.getMonth(), workingDate.getDate() + 1).getTime() <= targetDate.getTime()) {
|
|
232
|
+
workingDate.setDate(workingDate.getDate() + 1);
|
|
233
|
+
parts.days++;
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
remaining = targetDate.getTime() - workingDate.getTime();
|
|
237
|
+
}
|
|
238
|
+
if (include.hours) {
|
|
239
|
+
parts.hours = Math.floor(remaining / 3600000);
|
|
240
|
+
remaining %= 3600000;
|
|
241
|
+
}
|
|
242
|
+
if (include.minutes) {
|
|
243
|
+
parts.minutes = Math.floor(remaining / 60000);
|
|
244
|
+
remaining %= 60000;
|
|
245
|
+
}
|
|
246
|
+
if (include.seconds) {
|
|
247
|
+
parts.seconds = Math.floor(remaining / 1000);
|
|
248
|
+
remaining %= 1000;
|
|
249
|
+
}
|
|
250
|
+
if (include.milliseconds) {
|
|
251
|
+
parts.milliseconds = remaining;
|
|
252
|
+
}
|
|
253
|
+
// Totals
|
|
254
|
+
const totalMap = {
|
|
255
|
+
milliseconds: include.milliseconds ? totalMs : NaN,
|
|
256
|
+
seconds: include.seconds ? totalMs / 1000 : NaN,
|
|
257
|
+
minutes: include.minutes ? totalMs / 60000 : NaN,
|
|
258
|
+
hours: include.hours ? totalMs / 3600000 : NaN,
|
|
259
|
+
days: include.days ? totalMs / 86400000 : NaN,
|
|
260
|
+
months: include.months ? parts.years * 12 + parts.months + (parts.days || 0) / 30 : NaN,
|
|
261
|
+
years: include.years ? parts.years + (parts.months || 0) / 12 + (parts.days || 0) / 365 : NaN,
|
|
262
|
+
};
|
|
263
|
+
parts.total = +totalMs;
|
|
264
|
+
return parts;
|
|
265
|
+
}
|
package/dist/v1/basics/index.cjs
CHANGED
|
@@ -5,7 +5,6 @@ var replaceAsync = require('../../legacy/libs/replaceAsync.cjs');
|
|
|
5
5
|
var array = require('./array.cjs');
|
|
6
6
|
var clock = require('./clock.cjs');
|
|
7
7
|
var html = require('./html.cjs');
|
|
8
|
-
var html_deprecated = require('./html_deprecated.cjs');
|
|
9
8
|
var objFilter = require('./objFilter.cjs');
|
|
10
9
|
var objChecker = require('./objChecker.cjs');
|
|
11
10
|
var fullScreen = require('./fullScreen.cjs');
|
|
@@ -29,13 +28,6 @@ exports.readBase64Blob = html.readBase64Blob;
|
|
|
29
28
|
exports.readFileBlob = html.readFileBlob;
|
|
30
29
|
exports.readJsonBlob = html.readJsonBlob;
|
|
31
30
|
exports.saveJsonFile = html.saveJsonFile;
|
|
32
|
-
exports.areHtmlElsColliding = html_deprecated.areHtmlElsColliding;
|
|
33
|
-
exports.getHtmlElBorders = html_deprecated.getHtmlElBorders;
|
|
34
|
-
exports.getHtmlElBordersWidth = html_deprecated.getHtmlElBordersWidth;
|
|
35
|
-
exports.getHtmlElMargin = html_deprecated.getHtmlElMargin;
|
|
36
|
-
exports.getHtmlElPadding = html_deprecated.getHtmlElPadding;
|
|
37
|
-
exports.isInViewport = html_deprecated.isInViewport;
|
|
38
|
-
exports.isScrolledIntoView = html_deprecated.isScrolledIntoView;
|
|
39
31
|
exports.cloneObjTypeOrder = objFilter.cloneObjTypeOrder;
|
|
40
32
|
exports.extendObjType = objFilter.extendObjType;
|
|
41
33
|
exports.objType = objFilter.objType;
|
|
@@ -49,6 +41,8 @@ exports.isScreenFilled = fullScreen.isScreenFilled;
|
|
|
49
41
|
exports.offFullScreenChange = fullScreen.offFullScreenChange;
|
|
50
42
|
exports.onFullScreenChange = fullScreen.onFullScreenChange;
|
|
51
43
|
exports.requestFullScreen = fullScreen.requestFullScreen;
|
|
44
|
+
exports.calculateMarketcap = simpleMath.calculateMarketcap;
|
|
45
|
+
exports.compareMarketcap = simpleMath.compareMarketcap;
|
|
52
46
|
exports.formatBytes = simpleMath.formatBytes;
|
|
53
47
|
exports.genFibonacciSeq = simpleMath.genFibonacciSeq;
|
|
54
48
|
exports.getAge = simpleMath.getAge;
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { calculateMarketcap } from './simpleMath.mjs';
|
|
2
|
+
import { compareMarketcap } from './simpleMath.mjs';
|
|
1
3
|
import { getPercentage } from './simpleMath.mjs';
|
|
2
4
|
import { areElsCollTop } from './collision.mjs';
|
|
3
5
|
import { areElsCollBottom } from './collision.mjs';
|
|
@@ -17,15 +19,9 @@ import { getRectCenter } from './collision.mjs';
|
|
|
17
19
|
import { getElsRelativeCenterOffset } from './collision.mjs';
|
|
18
20
|
import { getElsCollDirDepth } from './collision.mjs';
|
|
19
21
|
import { getElsCollDetails } from './collision.mjs';
|
|
20
|
-
import { isInViewport } from './html_deprecated.mjs';
|
|
21
|
-
import { isScrolledIntoView } from './html_deprecated.mjs';
|
|
22
22
|
import { safeTextTrim } from './text.mjs';
|
|
23
23
|
import { installWindowHiddenScript } from './html.mjs';
|
|
24
24
|
import { genFibonacciSeq } from './simpleMath.mjs';
|
|
25
|
-
import { getHtmlElBorders } from './html_deprecated.mjs';
|
|
26
|
-
import { getHtmlElBordersWidth } from './html_deprecated.mjs';
|
|
27
|
-
import { getHtmlElMargin } from './html_deprecated.mjs';
|
|
28
|
-
import { getHtmlElPadding } from './html_deprecated.mjs';
|
|
29
25
|
import { fetchJson } from './html.mjs';
|
|
30
26
|
import { fetchText } from './html.mjs';
|
|
31
27
|
import { readJsonBlob } from './html.mjs';
|
|
@@ -39,7 +35,6 @@ import { exitFullScreen } from './fullScreen.mjs';
|
|
|
39
35
|
import { isFullScreenMode } from './fullScreen.mjs';
|
|
40
36
|
import { onFullScreenChange } from './fullScreen.mjs';
|
|
41
37
|
import { offFullScreenChange } from './fullScreen.mjs';
|
|
42
|
-
import { areHtmlElsColliding } from './html_deprecated.mjs';
|
|
43
38
|
import { isJsonObject } from './objChecker.mjs';
|
|
44
39
|
import arraySortPositions from '../../legacy/libs/arraySortPositions.mjs';
|
|
45
40
|
import { formatBytes } from './simpleMath.mjs';
|
|
@@ -60,5 +55,5 @@ import { getTimeDuration } from './clock.mjs';
|
|
|
60
55
|
import { shuffleArray } from './array.mjs';
|
|
61
56
|
import { toTitleCase } from './text.mjs';
|
|
62
57
|
import { toTitleCaseLowerFirst } from './text.mjs';
|
|
63
|
-
export { getPercentage, areElsCollTop, areElsCollBottom, areElsCollLeft, areElsCollRight, areElsCollPerfTop, areElsCollPerfBottom, areElsCollPerfLeft, areElsCollPerfRight, areElsColliding, areElsPerfColliding, getElsColliding, getElsPerfColliding, getElsCollOverlap, getElsCollOverlapPos, getRectCenter, getElsRelativeCenterOffset, getElsCollDirDepth, getElsCollDetails,
|
|
58
|
+
export { calculateMarketcap, compareMarketcap, getPercentage, areElsCollTop, areElsCollBottom, areElsCollLeft, areElsCollRight, areElsCollPerfTop, areElsCollPerfBottom, areElsCollPerfLeft, areElsCollPerfRight, areElsColliding, areElsPerfColliding, getElsColliding, getElsPerfColliding, getElsCollOverlap, getElsCollOverlapPos, getRectCenter, getElsRelativeCenterOffset, getElsCollDirDepth, getElsCollDetails, safeTextTrim, installWindowHiddenScript, genFibonacciSeq, fetchJson, fetchText, readJsonBlob, readFileBlob, readBase64Blob, saveJsonFile, documentIsFullScreen, isScreenFilled, requestFullScreen, exitFullScreen, isFullScreenMode, onFullScreenChange, offFullScreenChange, isJsonObject, arraySortPositions, formatBytes, addAiMarkerShortcut, extendObjType, reorderObjTypeOrder, cloneObjTypeOrder, countObj, objType, ruleOfThree, getSimplePerc, asyncReplace, getAge, formatCustomTimer, formatDayTimer, formatTimer, getTimeDuration, shuffleArray, toTitleCase, toTitleCaseLowerFirst };
|
|
64
59
|
//# sourceMappingURL=index.d.mts.map
|
package/dist/v1/basics/index.mjs
CHANGED
|
@@ -3,11 +3,10 @@ import asyncReplace from '../../legacy/libs/replaceAsync.mjs';
|
|
|
3
3
|
import { shuffleArray } from './array.mjs';
|
|
4
4
|
import { formatCustomTimer, formatDayTimer, formatTimer, getTimeDuration } from './clock.mjs';
|
|
5
5
|
import { readJsonBlob, saveJsonFile, fetchJson, installWindowHiddenScript, readFileBlob, readBase64Blob, fetchText, } from './html.mjs';
|
|
6
|
-
import { areHtmlElsColliding, getHtmlElBorders, getHtmlElBordersWidth, getHtmlElMargin, getHtmlElPadding, isInViewport, isScrolledIntoView, } from './html_deprecated.mjs';
|
|
7
6
|
import { extendObjType, reorderObjTypeOrder, cloneObjTypeOrder, objType } from './objFilter.mjs';
|
|
8
7
|
import { countObj, isJsonObject } from './objChecker.mjs';
|
|
9
8
|
import { documentIsFullScreen, isScreenFilled, requestFullScreen, exitFullScreen, isFullScreenMode, onFullScreenChange, offFullScreenChange, } from './fullScreen.mjs';
|
|
10
|
-
import { formatBytes, genFibonacciSeq, getAge, getPercentage, getSimplePerc, ruleOfThree, } from './simpleMath.mjs';
|
|
9
|
+
import { calculateMarketcap, compareMarketcap, formatBytes, genFibonacciSeq, getAge, getPercentage, getSimplePerc, ruleOfThree, } from './simpleMath.mjs';
|
|
11
10
|
import { addAiMarkerShortcut, safeTextTrim, toTitleCase, toTitleCaseLowerFirst } from './text.mjs';
|
|
12
11
|
import { areElsCollTop, areElsCollBottom, areElsCollLeft, areElsCollRight, areElsCollPerfTop, areElsCollPerfBottom, areElsCollPerfLeft, areElsCollPerfRight, areElsColliding, areElsPerfColliding, getElsColliding, getElsPerfColliding, getElsCollOverlap, getElsCollOverlapPos, getRectCenter, getElsRelativeCenterOffset, getElsCollDirDepth, getElsCollDetails, } from './collision.mjs';
|
|
13
|
-
export { getPercentage, areElsCollTop, areElsCollBottom, areElsCollLeft, areElsCollRight, areElsCollPerfTop, areElsCollPerfBottom, areElsCollPerfLeft, areElsCollPerfRight, areElsColliding, areElsPerfColliding, getElsColliding, getElsPerfColliding, getElsCollOverlap, getElsCollOverlapPos, getRectCenter, getElsRelativeCenterOffset, getElsCollDirDepth, getElsCollDetails,
|
|
12
|
+
export { calculateMarketcap, compareMarketcap, getPercentage, areElsCollTop, areElsCollBottom, areElsCollLeft, areElsCollRight, areElsCollPerfTop, areElsCollPerfBottom, areElsCollPerfLeft, areElsCollPerfRight, areElsColliding, areElsPerfColliding, getElsColliding, getElsPerfColliding, getElsCollOverlap, getElsCollOverlapPos, getRectCenter, getElsRelativeCenterOffset, getElsCollDirDepth, getElsCollDetails, safeTextTrim, installWindowHiddenScript, genFibonacciSeq, fetchJson, fetchText, readJsonBlob, readFileBlob, readBase64Blob, saveJsonFile, documentIsFullScreen, isScreenFilled, requestFullScreen, exitFullScreen, isFullScreenMode, onFullScreenChange, offFullScreenChange, isJsonObject, arraySortPositions, formatBytes, addAiMarkerShortcut, extendObjType, reorderObjTypeOrder, cloneObjTypeOrder, countObj, objType, ruleOfThree, getSimplePerc, asyncReplace, getAge, formatCustomTimer, formatDayTimer, formatTimer, getTimeDuration, shuffleArray, toTitleCase, toTitleCaseLowerFirst, };
|
|
@@ -181,6 +181,52 @@ function genFibonacciSeq({
|
|
|
181
181
|
return sequence;
|
|
182
182
|
}
|
|
183
183
|
|
|
184
|
+
/**
|
|
185
|
+
* Calculates the unit price of a coin or token based on the market capitalization and circulating supply.
|
|
186
|
+
*
|
|
187
|
+
* This function is typically used in financial contexts to determine the price
|
|
188
|
+
* of an asset by dividing its total market capitalization by its circulating supply.
|
|
189
|
+
*
|
|
190
|
+
* @param {number} originalMarketCap - The total market capitalization (e.g., in USD).
|
|
191
|
+
* @param {number} circulatingSupply - The number of coins/tokens currently in circulation.
|
|
192
|
+
* @returns {number} The calculated price per unit of the asset.
|
|
193
|
+
*/
|
|
194
|
+
function calculateMarketcap(originalMarketCap, circulatingSupply) {
|
|
195
|
+
if (Number.isNaN(originalMarketCap) || !Number.isFinite(originalMarketCap))
|
|
196
|
+
throw new TypeError('Original market cap must be a number.');
|
|
197
|
+
if (Number.isNaN(circulatingSupply) || !Number.isFinite(circulatingSupply))
|
|
198
|
+
throw new TypeError('Circulating supply must be a number.');
|
|
199
|
+
if (circulatingSupply <= 0) throw new Error('Circulating supply must be greater than zero.');
|
|
200
|
+
return originalMarketCap / circulatingSupply;
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
/**
|
|
204
|
+
* Calculates the new price of a coin when the market cap changes.
|
|
205
|
+
* @param {number} originalMarketCap - The original market cap.
|
|
206
|
+
* @param {number} circulatingSupply - The circulating supply.
|
|
207
|
+
* @param {number} newMarketCap - The new market cap.
|
|
208
|
+
* @returns {{
|
|
209
|
+
* originalPrice: number,
|
|
210
|
+
* newPrice: number,
|
|
211
|
+
* priceChangePercent: number
|
|
212
|
+
* }}
|
|
213
|
+
*/
|
|
214
|
+
function compareMarketcap(originalMarketCap, circulatingSupply, newMarketCap) {
|
|
215
|
+
if (Number.isNaN(newMarketCap) || !Number.isFinite(newMarketCap))
|
|
216
|
+
throw new TypeError('New market cap must be a number.');
|
|
217
|
+
const originalPrice = calculateMarketcap(originalMarketCap, circulatingSupply);
|
|
218
|
+
const newPrice = typeof newMarketCap === 'number' ? newMarketCap / circulatingSupply : NaN;
|
|
219
|
+
const priceChangePercent =
|
|
220
|
+
typeof newMarketCap === 'number' ? ((newPrice - originalPrice) / originalPrice) * 100 : NaN;
|
|
221
|
+
return {
|
|
222
|
+
originalPrice,
|
|
223
|
+
newPrice,
|
|
224
|
+
priceChangePercent,
|
|
225
|
+
};
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
exports.calculateMarketcap = calculateMarketcap;
|
|
229
|
+
exports.compareMarketcap = compareMarketcap;
|
|
184
230
|
exports.formatBytes = formatBytes;
|
|
185
231
|
exports.genFibonacciSeq = genFibonacciSeq;
|
|
186
232
|
exports.getAge = getAge;
|
|
@@ -112,6 +112,33 @@ export function genFibonacciSeq({ baseValues, length, combiner, }?: {
|
|
|
112
112
|
length?: number | undefined;
|
|
113
113
|
combiner?: ((a: number, b: number, index: number) => number) | undefined;
|
|
114
114
|
}): number[];
|
|
115
|
+
/**
|
|
116
|
+
* Calculates the unit price of a coin or token based on the market capitalization and circulating supply.
|
|
117
|
+
*
|
|
118
|
+
* This function is typically used in financial contexts to determine the price
|
|
119
|
+
* of an asset by dividing its total market capitalization by its circulating supply.
|
|
120
|
+
*
|
|
121
|
+
* @param {number} originalMarketCap - The total market capitalization (e.g., in USD).
|
|
122
|
+
* @param {number} circulatingSupply - The number of coins/tokens currently in circulation.
|
|
123
|
+
* @returns {number} The calculated price per unit of the asset.
|
|
124
|
+
*/
|
|
125
|
+
export function calculateMarketcap(originalMarketCap: number, circulatingSupply: number): number;
|
|
126
|
+
/**
|
|
127
|
+
* Calculates the new price of a coin when the market cap changes.
|
|
128
|
+
* @param {number} originalMarketCap - The original market cap.
|
|
129
|
+
* @param {number} circulatingSupply - The circulating supply.
|
|
130
|
+
* @param {number} newMarketCap - The new market cap.
|
|
131
|
+
* @returns {{
|
|
132
|
+
* originalPrice: number,
|
|
133
|
+
* newPrice: number,
|
|
134
|
+
* priceChangePercent: number
|
|
135
|
+
* }}
|
|
136
|
+
*/
|
|
137
|
+
export function compareMarketcap(originalMarketCap: number, circulatingSupply: number, newMarketCap: number): {
|
|
138
|
+
originalPrice: number;
|
|
139
|
+
newPrice: number;
|
|
140
|
+
priceChangePercent: number;
|
|
141
|
+
};
|
|
115
142
|
export type FormattedByteResult = {
|
|
116
143
|
/**
|
|
117
144
|
* - The resulting unit (e.g., 'MB', 'GB') or null if input is invalid.
|
|
@@ -158,3 +158,45 @@ export function genFibonacciSeq({ baseValues = [0, 1], length = 10, combiner = (
|
|
|
158
158
|
}
|
|
159
159
|
return sequence;
|
|
160
160
|
}
|
|
161
|
+
/**
|
|
162
|
+
* Calculates the unit price of a coin or token based on the market capitalization and circulating supply.
|
|
163
|
+
*
|
|
164
|
+
* This function is typically used in financial contexts to determine the price
|
|
165
|
+
* of an asset by dividing its total market capitalization by its circulating supply.
|
|
166
|
+
*
|
|
167
|
+
* @param {number} originalMarketCap - The total market capitalization (e.g., in USD).
|
|
168
|
+
* @param {number} circulatingSupply - The number of coins/tokens currently in circulation.
|
|
169
|
+
* @returns {number} The calculated price per unit of the asset.
|
|
170
|
+
*/
|
|
171
|
+
export function calculateMarketcap(originalMarketCap, circulatingSupply) {
|
|
172
|
+
if (Number.isNaN(originalMarketCap) || !Number.isFinite(originalMarketCap))
|
|
173
|
+
throw new TypeError('Original market cap must be a number.');
|
|
174
|
+
if (Number.isNaN(circulatingSupply) || !Number.isFinite(circulatingSupply))
|
|
175
|
+
throw new TypeError('Circulating supply must be a number.');
|
|
176
|
+
if (circulatingSupply <= 0)
|
|
177
|
+
throw new Error('Circulating supply must be greater than zero.');
|
|
178
|
+
return originalMarketCap / circulatingSupply;
|
|
179
|
+
}
|
|
180
|
+
/**
|
|
181
|
+
* Calculates the new price of a coin when the market cap changes.
|
|
182
|
+
* @param {number} originalMarketCap - The original market cap.
|
|
183
|
+
* @param {number} circulatingSupply - The circulating supply.
|
|
184
|
+
* @param {number} newMarketCap - The new market cap.
|
|
185
|
+
* @returns {{
|
|
186
|
+
* originalPrice: number,
|
|
187
|
+
* newPrice: number,
|
|
188
|
+
* priceChangePercent: number
|
|
189
|
+
* }}
|
|
190
|
+
*/
|
|
191
|
+
export function compareMarketcap(originalMarketCap, circulatingSupply, newMarketCap) {
|
|
192
|
+
if (Number.isNaN(newMarketCap) || !Number.isFinite(newMarketCap))
|
|
193
|
+
throw new TypeError('New market cap must be a number.');
|
|
194
|
+
const originalPrice = calculateMarketcap(originalMarketCap, circulatingSupply);
|
|
195
|
+
const newPrice = typeof newMarketCap === 'number' ? newMarketCap / circulatingSupply : NaN;
|
|
196
|
+
const priceChangePercent = typeof newMarketCap === 'number' ? ((newPrice - originalPrice) / originalPrice) * 100 : NaN;
|
|
197
|
+
return {
|
|
198
|
+
originalPrice,
|
|
199
|
+
newPrice,
|
|
200
|
+
priceChangePercent,
|
|
201
|
+
};
|
|
202
|
+
}
|