tiny-essentials 1.13.0 → 1.13.2
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 +1 -0
- package/dist/v1/TinyBasicsEs.js +139 -0
- package/dist/v1/TinyBasicsEs.min.js +1 -1
- package/dist/v1/TinyDragger.js +100 -0
- package/dist/v1/TinyEssentials.js +139 -0
- package/dist/v1/TinyEssentials.min.js +1 -1
- package/dist/v1/TinyUploadClicker.js +100 -0
- package/dist/v1/basics/html.cjs +101 -0
- package/dist/v1/basics/html.d.mts +15 -0
- package/dist/v1/basics/html.mjs +86 -0
- package/dist/v1/basics/index.cjs +2 -0
- package/dist/v1/basics/index.d.mts +3 -1
- package/dist/v1/basics/index.mjs +3 -3
- package/dist/v1/basics/simpleMath.cjs +38 -0
- package/dist/v1/basics/simpleMath.d.mts +24 -0
- package/dist/v1/basics/simpleMath.mjs +29 -0
- package/dist/v1/index.cjs +2 -0
- package/dist/v1/index.d.mts +3 -1
- package/dist/v1/index.mjs +3 -3
- package/docs/v1/basics/html.md +126 -23
- package/docs/v1/basics/simpleMath.md +28 -0
- package/package.json +1 -1
package/dist/v1/basics/html.cjs
CHANGED
|
@@ -252,11 +252,112 @@ const getHtmlElPadding = (el) => {
|
|
|
252
252
|
return { x, y, left, right, top, bottom };
|
|
253
253
|
};
|
|
254
254
|
|
|
255
|
+
/**
|
|
256
|
+
* Installs a script that toggles CSS classes on a given element
|
|
257
|
+
* based on the page's visibility or focus state.
|
|
258
|
+
*
|
|
259
|
+
* @param {Object} [settings={}]
|
|
260
|
+
* @param {HTMLElement} [settings.element=document.body] - The element to receive visibility classes.
|
|
261
|
+
* @param {string} [settings.hiddenClass='windowHidden'] - CSS class applied when the page is hidden.
|
|
262
|
+
* @param {string} [settings.visibleClass='windowVisible'] - CSS class applied when the page is visible.
|
|
263
|
+
* @returns {() => void} Function that removes all installed event listeners.
|
|
264
|
+
*/
|
|
265
|
+
function installWindowHiddenScript({
|
|
266
|
+
element = document.body,
|
|
267
|
+
hiddenClass = 'windowHidden',
|
|
268
|
+
visibleClass = 'windowVisible',
|
|
269
|
+
} = {}) {
|
|
270
|
+
const removeClass = () => {
|
|
271
|
+
element.classList.remove(hiddenClass);
|
|
272
|
+
element.classList.remove(visibleClass);
|
|
273
|
+
};
|
|
274
|
+
|
|
275
|
+
/** @type {string|null} */
|
|
276
|
+
let hiddenProp = null;
|
|
277
|
+
/** @type {(this: any, evt: Event) => void} */
|
|
278
|
+
let handler;
|
|
279
|
+
|
|
280
|
+
const visibilityEvents = [
|
|
281
|
+
'visibilitychange',
|
|
282
|
+
'mozvisibilitychange',
|
|
283
|
+
'webkitvisibilitychange',
|
|
284
|
+
'msvisibilitychange',
|
|
285
|
+
];
|
|
286
|
+
|
|
287
|
+
const visibilityProps = ['hidden', 'mozHidden', 'webkitHidden', 'msHidden'];
|
|
288
|
+
|
|
289
|
+
for (let i = 0; i < visibilityProps.length; i++) {
|
|
290
|
+
if (visibilityProps[i] in document) {
|
|
291
|
+
hiddenProp = visibilityProps[i];
|
|
292
|
+
break;
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
handler = function (evt) {
|
|
297
|
+
removeClass();
|
|
298
|
+
|
|
299
|
+
const type = evt?.type;
|
|
300
|
+
// @ts-ignore
|
|
301
|
+
const isHidden = hiddenProp && document[hiddenProp];
|
|
302
|
+
|
|
303
|
+
const visibleEvents = ['focus', 'focusin', 'pageshow'];
|
|
304
|
+
const hiddenEvents = ['blur', 'focusout', 'pagehide'];
|
|
305
|
+
|
|
306
|
+
if (visibleEvents.includes(type)) {
|
|
307
|
+
element.classList.add(visibleClass);
|
|
308
|
+
} else if (hiddenEvents.includes(type)) {
|
|
309
|
+
element.classList.add(hiddenClass);
|
|
310
|
+
} else {
|
|
311
|
+
element.classList.add(isHidden ? hiddenClass : visibleClass);
|
|
312
|
+
}
|
|
313
|
+
};
|
|
314
|
+
|
|
315
|
+
/** @type {() => void} */
|
|
316
|
+
let uninstall = () => {};
|
|
317
|
+
|
|
318
|
+
if (hiddenProp) {
|
|
319
|
+
const eventType = visibilityEvents[visibilityProps.indexOf(hiddenProp)];
|
|
320
|
+
document.addEventListener(eventType, handler);
|
|
321
|
+
window.addEventListener('focus', handler);
|
|
322
|
+
window.addEventListener('blur', handler);
|
|
323
|
+
|
|
324
|
+
uninstall = () => {
|
|
325
|
+
document.removeEventListener(eventType, handler);
|
|
326
|
+
window.removeEventListener('focus', handler);
|
|
327
|
+
window.removeEventListener('blur', handler);
|
|
328
|
+
removeClass();
|
|
329
|
+
};
|
|
330
|
+
} else if ('onfocusin' in document) {
|
|
331
|
+
// Fallback for IE9 and older
|
|
332
|
+
// @ts-ignore
|
|
333
|
+
document.onfocusin = document.onfocusout = handler;
|
|
334
|
+
uninstall = () => {
|
|
335
|
+
// @ts-ignore
|
|
336
|
+
document.onfocusin = document.onfocusout = null;
|
|
337
|
+
removeClass();
|
|
338
|
+
};
|
|
339
|
+
} else {
|
|
340
|
+
// Last resort fallback
|
|
341
|
+
window.onpageshow = window.onpagehide = window.onfocus = window.onblur = handler;
|
|
342
|
+
uninstall = () => {
|
|
343
|
+
window.onpageshow = window.onpagehide = window.onfocus = window.onblur = null;
|
|
344
|
+
removeClass();
|
|
345
|
+
};
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
// @ts-ignore
|
|
349
|
+
const simulatedEvent = new Event(hiddenProp && document[hiddenProp] ? 'blur' : 'focus');
|
|
350
|
+
handler(simulatedEvent);
|
|
351
|
+
|
|
352
|
+
return uninstall;
|
|
353
|
+
}
|
|
354
|
+
|
|
255
355
|
exports.areHtmlElsColliding = areHtmlElsColliding;
|
|
256
356
|
exports.fetchJson = fetchJson;
|
|
257
357
|
exports.getHtmlElBorders = getHtmlElBorders;
|
|
258
358
|
exports.getHtmlElBordersWidth = getHtmlElBordersWidth;
|
|
259
359
|
exports.getHtmlElMargin = getHtmlElMargin;
|
|
260
360
|
exports.getHtmlElPadding = getHtmlElPadding;
|
|
361
|
+
exports.installWindowHiddenScript = installWindowHiddenScript;
|
|
261
362
|
exports.readJsonBlob = readJsonBlob;
|
|
262
363
|
exports.saveJsonFile = saveJsonFile;
|
|
@@ -42,6 +42,21 @@ export function fetchJson(url: string, { method, body, timeout, retries, headers
|
|
|
42
42
|
headers?: Headers | Record<string, any> | undefined;
|
|
43
43
|
signal?: AbortSignal | null | undefined;
|
|
44
44
|
}): Promise<any>;
|
|
45
|
+
/**
|
|
46
|
+
* Installs a script that toggles CSS classes on a given element
|
|
47
|
+
* based on the page's visibility or focus state.
|
|
48
|
+
*
|
|
49
|
+
* @param {Object} [settings={}]
|
|
50
|
+
* @param {HTMLElement} [settings.element=document.body] - The element to receive visibility classes.
|
|
51
|
+
* @param {string} [settings.hiddenClass='windowHidden'] - CSS class applied when the page is hidden.
|
|
52
|
+
* @param {string} [settings.visibleClass='windowVisible'] - CSS class applied when the page is visible.
|
|
53
|
+
* @returns {() => void} Function that removes all installed event listeners.
|
|
54
|
+
*/
|
|
55
|
+
export function installWindowHiddenScript({ element, hiddenClass, visibleClass, }?: {
|
|
56
|
+
element?: HTMLElement | undefined;
|
|
57
|
+
hiddenClass?: string | undefined;
|
|
58
|
+
visibleClass?: string | undefined;
|
|
59
|
+
}): () => void;
|
|
45
60
|
export function getHtmlElBordersWidth(el: Element): HtmlElBoxSides;
|
|
46
61
|
export function getHtmlElBorders(el: Element): HtmlElBoxSides;
|
|
47
62
|
export function getHtmlElMargin(el: Element): HtmlElBoxSides;
|
package/dist/v1/basics/html.mjs
CHANGED
|
@@ -206,3 +206,89 @@ export const getHtmlElPadding = (el) => {
|
|
|
206
206
|
const y = top + bottom;
|
|
207
207
|
return { x, y, left, right, top, bottom };
|
|
208
208
|
};
|
|
209
|
+
/**
|
|
210
|
+
* Installs a script that toggles CSS classes on a given element
|
|
211
|
+
* based on the page's visibility or focus state.
|
|
212
|
+
*
|
|
213
|
+
* @param {Object} [settings={}]
|
|
214
|
+
* @param {HTMLElement} [settings.element=document.body] - The element to receive visibility classes.
|
|
215
|
+
* @param {string} [settings.hiddenClass='windowHidden'] - CSS class applied when the page is hidden.
|
|
216
|
+
* @param {string} [settings.visibleClass='windowVisible'] - CSS class applied when the page is visible.
|
|
217
|
+
* @returns {() => void} Function that removes all installed event listeners.
|
|
218
|
+
*/
|
|
219
|
+
export function installWindowHiddenScript({ element = document.body, hiddenClass = 'windowHidden', visibleClass = 'windowVisible', } = {}) {
|
|
220
|
+
const removeClass = () => {
|
|
221
|
+
element.classList.remove(hiddenClass);
|
|
222
|
+
element.classList.remove(visibleClass);
|
|
223
|
+
};
|
|
224
|
+
/** @type {string|null} */
|
|
225
|
+
let hiddenProp = null;
|
|
226
|
+
/** @type {(this: any, evt: Event) => void} */
|
|
227
|
+
let handler;
|
|
228
|
+
const visibilityEvents = [
|
|
229
|
+
'visibilitychange',
|
|
230
|
+
'mozvisibilitychange',
|
|
231
|
+
'webkitvisibilitychange',
|
|
232
|
+
'msvisibilitychange',
|
|
233
|
+
];
|
|
234
|
+
const visibilityProps = ['hidden', 'mozHidden', 'webkitHidden', 'msHidden'];
|
|
235
|
+
for (let i = 0; i < visibilityProps.length; i++) {
|
|
236
|
+
if (visibilityProps[i] in document) {
|
|
237
|
+
hiddenProp = visibilityProps[i];
|
|
238
|
+
break;
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
handler = function (evt) {
|
|
242
|
+
removeClass();
|
|
243
|
+
const type = evt?.type;
|
|
244
|
+
// @ts-ignore
|
|
245
|
+
const isHidden = hiddenProp && document[hiddenProp];
|
|
246
|
+
const visibleEvents = ['focus', 'focusin', 'pageshow'];
|
|
247
|
+
const hiddenEvents = ['blur', 'focusout', 'pagehide'];
|
|
248
|
+
if (visibleEvents.includes(type)) {
|
|
249
|
+
element.classList.add(visibleClass);
|
|
250
|
+
}
|
|
251
|
+
else if (hiddenEvents.includes(type)) {
|
|
252
|
+
element.classList.add(hiddenClass);
|
|
253
|
+
}
|
|
254
|
+
else {
|
|
255
|
+
element.classList.add(isHidden ? hiddenClass : visibleClass);
|
|
256
|
+
}
|
|
257
|
+
};
|
|
258
|
+
/** @type {() => void} */
|
|
259
|
+
let uninstall = () => { };
|
|
260
|
+
if (hiddenProp) {
|
|
261
|
+
const eventType = visibilityEvents[visibilityProps.indexOf(hiddenProp)];
|
|
262
|
+
document.addEventListener(eventType, handler);
|
|
263
|
+
window.addEventListener('focus', handler);
|
|
264
|
+
window.addEventListener('blur', handler);
|
|
265
|
+
uninstall = () => {
|
|
266
|
+
document.removeEventListener(eventType, handler);
|
|
267
|
+
window.removeEventListener('focus', handler);
|
|
268
|
+
window.removeEventListener('blur', handler);
|
|
269
|
+
removeClass();
|
|
270
|
+
};
|
|
271
|
+
}
|
|
272
|
+
else if ('onfocusin' in document) {
|
|
273
|
+
// Fallback for IE9 and older
|
|
274
|
+
// @ts-ignore
|
|
275
|
+
document.onfocusin = document.onfocusout = handler;
|
|
276
|
+
uninstall = () => {
|
|
277
|
+
// @ts-ignore
|
|
278
|
+
document.onfocusin = document.onfocusout = null;
|
|
279
|
+
removeClass();
|
|
280
|
+
};
|
|
281
|
+
}
|
|
282
|
+
else {
|
|
283
|
+
// Last resort fallback
|
|
284
|
+
window.onpageshow = window.onpagehide = window.onfocus = window.onblur = handler;
|
|
285
|
+
uninstall = () => {
|
|
286
|
+
window.onpageshow = window.onpagehide = window.onfocus = window.onblur = null;
|
|
287
|
+
removeClass();
|
|
288
|
+
};
|
|
289
|
+
}
|
|
290
|
+
// @ts-ignore
|
|
291
|
+
const simulatedEvent = new Event(hiddenProp && document[hiddenProp] ? 'blur' : 'focus');
|
|
292
|
+
handler(simulatedEvent);
|
|
293
|
+
return uninstall;
|
|
294
|
+
}
|
package/dist/v1/basics/index.cjs
CHANGED
|
@@ -25,6 +25,7 @@ exports.getHtmlElBorders = html.getHtmlElBorders;
|
|
|
25
25
|
exports.getHtmlElBordersWidth = html.getHtmlElBordersWidth;
|
|
26
26
|
exports.getHtmlElMargin = html.getHtmlElMargin;
|
|
27
27
|
exports.getHtmlElPadding = html.getHtmlElPadding;
|
|
28
|
+
exports.installWindowHiddenScript = html.installWindowHiddenScript;
|
|
28
29
|
exports.readJsonBlob = html.readJsonBlob;
|
|
29
30
|
exports.saveJsonFile = html.saveJsonFile;
|
|
30
31
|
exports.cloneObjTypeOrder = objFilter.cloneObjTypeOrder;
|
|
@@ -41,6 +42,7 @@ exports.offFullScreenChange = fullScreen.offFullScreenChange;
|
|
|
41
42
|
exports.onFullScreenChange = fullScreen.onFullScreenChange;
|
|
42
43
|
exports.requestFullScreen = fullScreen.requestFullScreen;
|
|
43
44
|
exports.formatBytes = simpleMath.formatBytes;
|
|
45
|
+
exports.genFibonacciSeq = simpleMath.genFibonacciSeq;
|
|
44
46
|
exports.getAge = simpleMath.getAge;
|
|
45
47
|
exports.getSimplePerc = simpleMath.getSimplePerc;
|
|
46
48
|
exports.ruleOfThree = simpleMath.ruleOfThree;
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { installWindowHiddenScript } from './html.mjs';
|
|
2
|
+
import { genFibonacciSeq } from './simpleMath.mjs';
|
|
1
3
|
import { getHtmlElBorders } from './html.mjs';
|
|
2
4
|
import { getHtmlElBordersWidth } from './html.mjs';
|
|
3
5
|
import { getHtmlElMargin } from './html.mjs';
|
|
@@ -33,5 +35,5 @@ import { getTimeDuration } from './clock.mjs';
|
|
|
33
35
|
import { shuffleArray } from './array.mjs';
|
|
34
36
|
import { toTitleCase } from './text.mjs';
|
|
35
37
|
import { toTitleCaseLowerFirst } from './text.mjs';
|
|
36
|
-
export { getHtmlElBorders, getHtmlElBordersWidth, getHtmlElMargin, getHtmlElPadding, fetchJson, readJsonBlob, saveJsonFile, documentIsFullScreen, isScreenFilled, requestFullScreen, exitFullScreen, isFullScreenMode, onFullScreenChange, offFullScreenChange, areHtmlElsColliding, isJsonObject, arraySortPositions, formatBytes, addAiMarkerShortcut, extendObjType, reorderObjTypeOrder, cloneObjTypeOrder, countObj, objType, ruleOfThree, getSimplePerc, asyncReplace, getAge, formatCustomTimer, formatDayTimer, formatTimer, getTimeDuration, shuffleArray, toTitleCase, toTitleCaseLowerFirst };
|
|
38
|
+
export { installWindowHiddenScript, genFibonacciSeq, getHtmlElBorders, getHtmlElBordersWidth, getHtmlElMargin, getHtmlElPadding, fetchJson, readJsonBlob, saveJsonFile, documentIsFullScreen, isScreenFilled, requestFullScreen, exitFullScreen, isFullScreenMode, onFullScreenChange, offFullScreenChange, areHtmlElsColliding, isJsonObject, arraySortPositions, formatBytes, addAiMarkerShortcut, extendObjType, reorderObjTypeOrder, cloneObjTypeOrder, countObj, objType, ruleOfThree, getSimplePerc, asyncReplace, getAge, formatCustomTimer, formatDayTimer, formatTimer, getTimeDuration, shuffleArray, toTitleCase, toTitleCaseLowerFirst };
|
|
37
39
|
//# sourceMappingURL=index.d.mts.map
|
package/dist/v1/basics/index.mjs
CHANGED
|
@@ -2,9 +2,9 @@ import arraySortPositions from '../../legacy/libs/arraySortPositions.mjs';
|
|
|
2
2
|
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
|
-
import { areHtmlElsColliding, readJsonBlob, saveJsonFile, fetchJson, getHtmlElBorders, getHtmlElBordersWidth, getHtmlElMargin, getHtmlElPadding, } from './html.mjs';
|
|
5
|
+
import { areHtmlElsColliding, readJsonBlob, saveJsonFile, fetchJson, getHtmlElBorders, getHtmlElBordersWidth, getHtmlElMargin, getHtmlElPadding, installWindowHiddenScript, } from './html.mjs';
|
|
6
6
|
import { countObj, extendObjType, reorderObjTypeOrder, cloneObjTypeOrder, objType, isJsonObject, } from './objFilter.mjs';
|
|
7
7
|
import { documentIsFullScreen, isScreenFilled, requestFullScreen, exitFullScreen, isFullScreenMode, onFullScreenChange, offFullScreenChange, } from './fullScreen.mjs';
|
|
8
|
-
import { formatBytes, getAge, getSimplePerc, ruleOfThree } from './simpleMath.mjs';
|
|
8
|
+
import { formatBytes, genFibonacciSeq, getAge, getSimplePerc, ruleOfThree } from './simpleMath.mjs';
|
|
9
9
|
import { addAiMarkerShortcut, toTitleCase, toTitleCaseLowerFirst } from './text.mjs';
|
|
10
|
-
export { getHtmlElBorders, getHtmlElBordersWidth, getHtmlElMargin, getHtmlElPadding, fetchJson, readJsonBlob, saveJsonFile, documentIsFullScreen, isScreenFilled, requestFullScreen, exitFullScreen, isFullScreenMode, onFullScreenChange, offFullScreenChange, areHtmlElsColliding, isJsonObject, arraySortPositions, formatBytes, addAiMarkerShortcut, extendObjType, reorderObjTypeOrder, cloneObjTypeOrder, countObj, objType, ruleOfThree, getSimplePerc, asyncReplace, getAge, formatCustomTimer, formatDayTimer, formatTimer, getTimeDuration, shuffleArray, toTitleCase, toTitleCaseLowerFirst, };
|
|
10
|
+
export { installWindowHiddenScript, genFibonacciSeq, getHtmlElBorders, getHtmlElBordersWidth, getHtmlElMargin, getHtmlElPadding, fetchJson, readJsonBlob, saveJsonFile, documentIsFullScreen, isScreenFilled, requestFullScreen, exitFullScreen, isFullScreenMode, onFullScreenChange, offFullScreenChange, areHtmlElsColliding, isJsonObject, arraySortPositions, formatBytes, addAiMarkerShortcut, extendObjType, reorderObjTypeOrder, cloneObjTypeOrder, countObj, objType, ruleOfThree, getSimplePerc, asyncReplace, getAge, formatCustomTimer, formatDayTimer, formatTimer, getTimeDuration, shuffleArray, toTitleCase, toTitleCaseLowerFirst, };
|
|
@@ -126,7 +126,45 @@ function formatBytes(bytes, decimals = null, maxUnit = null) {
|
|
|
126
126
|
return { unit, value };
|
|
127
127
|
}
|
|
128
128
|
|
|
129
|
+
/**
|
|
130
|
+
* Generates a Fibonacci-like sequence as an array of vectors.
|
|
131
|
+
*
|
|
132
|
+
* @param {Object} [settings={}]
|
|
133
|
+
* @param {number[]} [settings.baseValues=[0, 1]] - An array of two starting numbers (e.g. [0, 1] or [1, 1]).
|
|
134
|
+
* @param {number} [settings.length=10] - Total number of items to generate in the sequence.
|
|
135
|
+
* @param {(a: number, b: number, index: number) => number} [settings.combiner=((a, b) => a + b)] - A custom function to combine previous two numbers.
|
|
136
|
+
* @returns {number[]} The resulting Fibonacci sequence.
|
|
137
|
+
*
|
|
138
|
+
* FibonacciVectors2D
|
|
139
|
+
* @example
|
|
140
|
+
* generateFibonacciSequence({
|
|
141
|
+
* baseValues: [[0, 1], [1, 1]],
|
|
142
|
+
* length: 10,
|
|
143
|
+
* combiner: ([x1, y1], [x2, y2]) => [x1 + x2, y1 + y2]
|
|
144
|
+
* });
|
|
145
|
+
*
|
|
146
|
+
* @beta
|
|
147
|
+
*/
|
|
148
|
+
function genFibonacciSeq({
|
|
149
|
+
baseValues = [0, 1],
|
|
150
|
+
length = 10,
|
|
151
|
+
combiner = (a, b) => a + b,
|
|
152
|
+
} = {}) {
|
|
153
|
+
if (!Array.isArray(baseValues) || baseValues.length !== 2)
|
|
154
|
+
throw new Error('baseValues must be an array of exactly two numbers');
|
|
155
|
+
|
|
156
|
+
const sequence = [...baseValues.slice(0, 2)];
|
|
157
|
+
|
|
158
|
+
for (let i = 2; i < length; i++) {
|
|
159
|
+
const next = combiner(sequence[i - 2], sequence[i - 1], i);
|
|
160
|
+
sequence.push(next);
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
return sequence;
|
|
164
|
+
}
|
|
165
|
+
|
|
129
166
|
exports.formatBytes = formatBytes;
|
|
167
|
+
exports.genFibonacciSeq = genFibonacciSeq;
|
|
130
168
|
exports.getAge = getAge;
|
|
131
169
|
exports.getSimplePerc = getSimplePerc;
|
|
132
170
|
exports.ruleOfThree = ruleOfThree;
|
|
@@ -74,6 +74,30 @@ export function getAge(timeData?: number | string | Date, now?: Date | null): nu
|
|
|
74
74
|
* // → { unit: 'MB', value: 1024 }
|
|
75
75
|
*/
|
|
76
76
|
export function formatBytes(bytes: number, decimals?: number | null, maxUnit?: string | null): FormattedByteResult;
|
|
77
|
+
/**
|
|
78
|
+
* Generates a Fibonacci-like sequence as an array of vectors.
|
|
79
|
+
*
|
|
80
|
+
* @param {Object} [settings={}]
|
|
81
|
+
* @param {number[]} [settings.baseValues=[0, 1]] - An array of two starting numbers (e.g. [0, 1] or [1, 1]).
|
|
82
|
+
* @param {number} [settings.length=10] - Total number of items to generate in the sequence.
|
|
83
|
+
* @param {(a: number, b: number, index: number) => number} [settings.combiner=((a, b) => a + b)] - A custom function to combine previous two numbers.
|
|
84
|
+
* @returns {number[]} The resulting Fibonacci sequence.
|
|
85
|
+
*
|
|
86
|
+
* FibonacciVectors2D
|
|
87
|
+
* @example
|
|
88
|
+
* generateFibonacciSequence({
|
|
89
|
+
* baseValues: [[0, 1], [1, 1]],
|
|
90
|
+
* length: 10,
|
|
91
|
+
* combiner: ([x1, y1], [x2, y2]) => [x1 + x2, y1 + y2]
|
|
92
|
+
* });
|
|
93
|
+
*
|
|
94
|
+
* @beta
|
|
95
|
+
*/
|
|
96
|
+
export function genFibonacciSeq({ baseValues, length, combiner, }?: {
|
|
97
|
+
baseValues?: number[] | undefined;
|
|
98
|
+
length?: number | undefined;
|
|
99
|
+
combiner?: ((a: number, b: number, index: number) => number) | undefined;
|
|
100
|
+
}): number[];
|
|
77
101
|
export type FormattedByteResult = {
|
|
78
102
|
/**
|
|
79
103
|
* - The resulting unit (e.g., 'MB', 'GB') or null if input is invalid.
|
|
@@ -111,3 +111,32 @@ export function formatBytes(bytes, decimals = null, maxUnit = null) {
|
|
|
111
111
|
const unit = sizes[i];
|
|
112
112
|
return { unit, value };
|
|
113
113
|
}
|
|
114
|
+
/**
|
|
115
|
+
* Generates a Fibonacci-like sequence as an array of vectors.
|
|
116
|
+
*
|
|
117
|
+
* @param {Object} [settings={}]
|
|
118
|
+
* @param {number[]} [settings.baseValues=[0, 1]] - An array of two starting numbers (e.g. [0, 1] or [1, 1]).
|
|
119
|
+
* @param {number} [settings.length=10] - Total number of items to generate in the sequence.
|
|
120
|
+
* @param {(a: number, b: number, index: number) => number} [settings.combiner=((a, b) => a + b)] - A custom function to combine previous two numbers.
|
|
121
|
+
* @returns {number[]} The resulting Fibonacci sequence.
|
|
122
|
+
*
|
|
123
|
+
* FibonacciVectors2D
|
|
124
|
+
* @example
|
|
125
|
+
* generateFibonacciSequence({
|
|
126
|
+
* baseValues: [[0, 1], [1, 1]],
|
|
127
|
+
* length: 10,
|
|
128
|
+
* combiner: ([x1, y1], [x2, y2]) => [x1 + x2, y1 + y2]
|
|
129
|
+
* });
|
|
130
|
+
*
|
|
131
|
+
* @beta
|
|
132
|
+
*/
|
|
133
|
+
export function genFibonacciSeq({ baseValues = [0, 1], length = 10, combiner = (a, b) => a + b, } = {}) {
|
|
134
|
+
if (!Array.isArray(baseValues) || baseValues.length !== 2)
|
|
135
|
+
throw new Error('baseValues must be an array of exactly two numbers');
|
|
136
|
+
const sequence = [...baseValues.slice(0, 2)];
|
|
137
|
+
for (let i = 2; i < length; i++) {
|
|
138
|
+
const next = combiner(sequence[i - 2], sequence[i - 1], i);
|
|
139
|
+
sequence.push(next);
|
|
140
|
+
}
|
|
141
|
+
return sequence;
|
|
142
|
+
}
|
package/dist/v1/index.cjs
CHANGED
|
@@ -46,6 +46,7 @@ exports.offFullScreenChange = fullScreen.offFullScreenChange;
|
|
|
46
46
|
exports.onFullScreenChange = fullScreen.onFullScreenChange;
|
|
47
47
|
exports.requestFullScreen = fullScreen.requestFullScreen;
|
|
48
48
|
exports.formatBytes = simpleMath.formatBytes;
|
|
49
|
+
exports.genFibonacciSeq = simpleMath.genFibonacciSeq;
|
|
49
50
|
exports.getAge = simpleMath.getAge;
|
|
50
51
|
exports.getSimplePerc = simpleMath.getSimplePerc;
|
|
51
52
|
exports.ruleOfThree = simpleMath.ruleOfThree;
|
|
@@ -63,6 +64,7 @@ exports.getHtmlElBorders = html.getHtmlElBorders;
|
|
|
63
64
|
exports.getHtmlElBordersWidth = html.getHtmlElBordersWidth;
|
|
64
65
|
exports.getHtmlElMargin = html.getHtmlElMargin;
|
|
65
66
|
exports.getHtmlElPadding = html.getHtmlElPadding;
|
|
67
|
+
exports.installWindowHiddenScript = html.installWindowHiddenScript;
|
|
66
68
|
exports.readJsonBlob = html.readJsonBlob;
|
|
67
69
|
exports.saveJsonFile = html.saveJsonFile;
|
|
68
70
|
exports.TinyDragDropDetector = TinyDragDropDetector;
|
package/dist/v1/index.d.mts
CHANGED
|
@@ -7,6 +7,8 @@ import TinyRateLimiter from './libs/TinyRateLimiter.mjs';
|
|
|
7
7
|
import ColorSafeStringify from './libs/ColorSafeStringify.mjs';
|
|
8
8
|
import TinyPromiseQueue from './libs/TinyPromiseQueue.mjs';
|
|
9
9
|
import TinyLevelUp from '../legacy/libs/userLevel.mjs';
|
|
10
|
+
import { installWindowHiddenScript } from './basics/html.mjs';
|
|
11
|
+
import { genFibonacciSeq } from './basics/simpleMath.mjs';
|
|
10
12
|
import { isDirEmptyAsync } from './fileManager/asyncFuncs.mjs';
|
|
11
13
|
import { fileSizeAsync } from './fileManager/asyncFuncs.mjs';
|
|
12
14
|
import { dirSizeAsync } from './fileManager/asyncFuncs.mjs';
|
|
@@ -71,5 +73,5 @@ import { getTimeDuration } from './basics/clock.mjs';
|
|
|
71
73
|
import { shuffleArray } from './basics/array.mjs';
|
|
72
74
|
import { toTitleCase } from './basics/text.mjs';
|
|
73
75
|
import { toTitleCaseLowerFirst } from './basics/text.mjs';
|
|
74
|
-
export { TinyDomReadyManager, TinyDragger, TinyDragDropDetector, TinyToastNotify, TinyNotifyCenter, TinyRateLimiter, ColorSafeStringify, TinyPromiseQueue, TinyLevelUp, isDirEmptyAsync, fileSizeAsync, dirSizeAsync, listFilesAsync, listDirsAsync, getHtmlElBorders, getHtmlElBordersWidth, getHtmlElMargin, getHtmlElPadding, getLatestBackupPath, fetchJson, readJsonBlob, saveJsonFile, readJsonFile, writeJsonFile, ensureDirectory, clearDirectoryAsync, clearDirectory, fileExists, dirExists, isDirEmpty, ensureCopyFile, tryDeleteFile, writeTextFile, listFiles, listDirs, fileSize, dirSize, backupFile, restoreLatestBackup, renameFileBatch, renameFileRegex, renameFileAddPrefixSuffix, renameFileNormalizeCase, renameFilePadNumbers, documentIsFullScreen, isScreenFilled, requestFullScreen, exitFullScreen, isFullScreenMode, onFullScreenChange, offFullScreenChange, areHtmlElsColliding, isJsonObject, arraySortPositions, formatBytes, addAiMarkerShortcut, extendObjType, reorderObjTypeOrder, cloneObjTypeOrder, countObj, checkObj, objType, ruleOfThree, getSimplePerc, asyncReplace, getAge, formatCustomTimer, formatDayTimer, formatTimer, getTimeDuration, shuffleArray, toTitleCase, toTitleCaseLowerFirst };
|
|
76
|
+
export { TinyDomReadyManager, TinyDragger, TinyDragDropDetector, TinyToastNotify, TinyNotifyCenter, TinyRateLimiter, ColorSafeStringify, TinyPromiseQueue, TinyLevelUp, installWindowHiddenScript, genFibonacciSeq, isDirEmptyAsync, fileSizeAsync, dirSizeAsync, listFilesAsync, listDirsAsync, getHtmlElBorders, getHtmlElBordersWidth, getHtmlElMargin, getHtmlElPadding, getLatestBackupPath, fetchJson, readJsonBlob, saveJsonFile, readJsonFile, writeJsonFile, ensureDirectory, clearDirectoryAsync, clearDirectory, fileExists, dirExists, isDirEmpty, ensureCopyFile, tryDeleteFile, writeTextFile, listFiles, listDirs, fileSize, dirSize, backupFile, restoreLatestBackup, renameFileBatch, renameFileRegex, renameFileAddPrefixSuffix, renameFileNormalizeCase, renameFilePadNumbers, documentIsFullScreen, isScreenFilled, requestFullScreen, exitFullScreen, isFullScreenMode, onFullScreenChange, offFullScreenChange, areHtmlElsColliding, isJsonObject, arraySortPositions, formatBytes, addAiMarkerShortcut, extendObjType, reorderObjTypeOrder, cloneObjTypeOrder, countObj, checkObj, objType, ruleOfThree, getSimplePerc, asyncReplace, getAge, formatCustomTimer, formatDayTimer, formatTimer, getTimeDuration, shuffleArray, toTitleCase, toTitleCaseLowerFirst };
|
|
75
77
|
//# sourceMappingURL=index.d.mts.map
|
package/dist/v1/index.mjs
CHANGED
|
@@ -5,17 +5,17 @@ import { shuffleArray } from './basics/array.mjs';
|
|
|
5
5
|
import { formatCustomTimer, formatDayTimer, formatTimer, getTimeDuration, } from './basics/clock.mjs';
|
|
6
6
|
import { countObj, extendObjType, reorderObjTypeOrder, cloneObjTypeOrder, objType, checkObj, isJsonObject, } from './basics/objFilter.mjs';
|
|
7
7
|
import { documentIsFullScreen, isScreenFilled, requestFullScreen, exitFullScreen, isFullScreenMode, onFullScreenChange, offFullScreenChange, } from './basics/fullScreen.mjs';
|
|
8
|
-
import { formatBytes, getAge, getSimplePerc, ruleOfThree } from './basics/simpleMath.mjs';
|
|
8
|
+
import { formatBytes, genFibonacciSeq, getAge, getSimplePerc, ruleOfThree, } from './basics/simpleMath.mjs';
|
|
9
9
|
import { addAiMarkerShortcut, toTitleCase, toTitleCaseLowerFirst } from './basics/text.mjs';
|
|
10
10
|
import ColorSafeStringify from './libs/ColorSafeStringify.mjs';
|
|
11
11
|
import TinyPromiseQueue from './libs/TinyPromiseQueue.mjs';
|
|
12
12
|
import TinyRateLimiter from './libs/TinyRateLimiter.mjs';
|
|
13
13
|
import TinyNotifyCenter from './libs/TinyNotifyCenter.mjs';
|
|
14
14
|
import TinyToastNotify from './libs/TinyToastNotify.mjs';
|
|
15
|
-
import { areHtmlElsColliding, readJsonBlob, saveJsonFile, fetchJson, getHtmlElBorders, getHtmlElBordersWidth, getHtmlElMargin, getHtmlElPadding, } from './basics/html.mjs';
|
|
15
|
+
import { areHtmlElsColliding, readJsonBlob, saveJsonFile, fetchJson, getHtmlElBorders, getHtmlElBordersWidth, getHtmlElMargin, getHtmlElPadding, installWindowHiddenScript, } from './basics/html.mjs';
|
|
16
16
|
import TinyDragDropDetector from './libs/TinyDragDropDetector.mjs';
|
|
17
17
|
import { readJsonFile, writeJsonFile, ensureDirectory, clearDirectory, fileExists, dirExists, isDirEmpty, ensureCopyFile, tryDeleteFile, writeTextFile, listFiles, listDirs, fileSize, dirSize, backupFile, restoreLatestBackup, renameFileBatch, renameFileRegex, renameFileAddPrefixSuffix, renameFileNormalizeCase, renameFilePadNumbers, getLatestBackupPath, } from './fileManager/normalFuncs.mjs';
|
|
18
18
|
import { listFilesAsync, listDirsAsync, clearDirectoryAsync, isDirEmptyAsync, fileSizeAsync, dirSizeAsync, } from './fileManager/asyncFuncs.mjs';
|
|
19
19
|
import TinyDragger from './libs/TinyDragger.mjs';
|
|
20
20
|
import TinyDomReadyManager from './libs/TinyDomReadyManager.mjs';
|
|
21
|
-
export { TinyDomReadyManager, TinyDragger, TinyDragDropDetector, TinyToastNotify, TinyNotifyCenter, TinyRateLimiter, ColorSafeStringify, TinyPromiseQueue, TinyLevelUp, isDirEmptyAsync, fileSizeAsync, dirSizeAsync, listFilesAsync, listDirsAsync, getHtmlElBorders, getHtmlElBordersWidth, getHtmlElMargin, getHtmlElPadding, getLatestBackupPath, fetchJson, readJsonBlob, saveJsonFile, readJsonFile, writeJsonFile, ensureDirectory, clearDirectoryAsync, clearDirectory, fileExists, dirExists, isDirEmpty, ensureCopyFile, tryDeleteFile, writeTextFile, listFiles, listDirs, fileSize, dirSize, backupFile, restoreLatestBackup, renameFileBatch, renameFileRegex, renameFileAddPrefixSuffix, renameFileNormalizeCase, renameFilePadNumbers, documentIsFullScreen, isScreenFilled, requestFullScreen, exitFullScreen, isFullScreenMode, onFullScreenChange, offFullScreenChange, areHtmlElsColliding, isJsonObject, arraySortPositions, formatBytes, addAiMarkerShortcut, extendObjType, reorderObjTypeOrder, cloneObjTypeOrder, countObj, checkObj, objType, ruleOfThree, getSimplePerc, asyncReplace, getAge, formatCustomTimer, formatDayTimer, formatTimer, getTimeDuration, shuffleArray, toTitleCase, toTitleCaseLowerFirst, };
|
|
21
|
+
export { TinyDomReadyManager, TinyDragger, TinyDragDropDetector, TinyToastNotify, TinyNotifyCenter, TinyRateLimiter, ColorSafeStringify, TinyPromiseQueue, TinyLevelUp, installWindowHiddenScript, genFibonacciSeq, isDirEmptyAsync, fileSizeAsync, dirSizeAsync, listFilesAsync, listDirsAsync, getHtmlElBorders, getHtmlElBordersWidth, getHtmlElMargin, getHtmlElPadding, getLatestBackupPath, fetchJson, readJsonBlob, saveJsonFile, readJsonFile, writeJsonFile, ensureDirectory, clearDirectoryAsync, clearDirectory, fileExists, dirExists, isDirEmpty, ensureCopyFile, tryDeleteFile, writeTextFile, listFiles, listDirs, fileSize, dirSize, backupFile, restoreLatestBackup, renameFileBatch, renameFileRegex, renameFileAddPrefixSuffix, renameFileNormalizeCase, renameFilePadNumbers, documentIsFullScreen, isScreenFilled, requestFullScreen, exitFullScreen, isFullScreenMode, onFullScreenChange, offFullScreenChange, areHtmlElsColliding, isJsonObject, arraySortPositions, formatBytes, addAiMarkerShortcut, extendObjType, reorderObjTypeOrder, cloneObjTypeOrder, countObj, checkObj, objType, ruleOfThree, getSimplePerc, asyncReplace, getAge, formatCustomTimer, formatDayTimer, formatTimer, getTimeDuration, shuffleArray, toTitleCase, toTitleCaseLowerFirst, };
|