@lowentry/utils 2.0.4 → 2.0.7

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/dist/index.d.ts CHANGED
@@ -1,11 +1,1045 @@
1
- import * as LeUtilsFunctions from './LeUtils';
2
- export * from './LeTypes';
3
- export * from './LeUtils';
4
- export * from './classes/EventEmitter';
5
- export * from './classes/LinkedList';
6
- export * from './classes/SerializableMap';
7
- export * from './classes/TreeSet';
8
- export declare const LeUtils: {
1
+ /**
2
+ * LeUtils - Core utility functions
3
+ */
4
+ /**
5
+ * Transactional Value Types
6
+ */
7
+ interface TransactionChange {
8
+ id: string;
9
+ value: unknown;
10
+ }
11
+ interface TransactionalValue {
12
+ value: unknown;
13
+ changes: TransactionChange[];
14
+ }
15
+ /**
16
+ * Deep equality comparison.
17
+ * Compares objects, arrays, Maps, Sets, primitives, and handles special cases.
18
+ *
19
+ * @param a - First value to compare
20
+ * @param b - Second value to compare
21
+ * @returns true if values are equivalent
22
+ */
23
+ declare function equals(a: unknown, b: unknown): boolean;
24
+ /**
25
+ * Deep clones a value.
26
+ *
27
+ * @param value - Value to clone
28
+ * @returns Deep cloned value
29
+ */
30
+ declare function clone<T>(value: T): T;
31
+ /**
32
+ * Checks if the given elements can be iterated over using each().
33
+ *
34
+ * @param elements - Value to check
35
+ * @returns true if can iterate
36
+ */
37
+ declare function supportsEach(elements: unknown): boolean;
38
+ /**
39
+ * Returns an iterator that yields [value, key/index] for each element.
40
+ *
41
+ * @param elements - Collection to iterate
42
+ * @param optionalSkipHasOwnPropertyCheck - Skip hasOwnProperty check
43
+ * @yields [value, key/index]
44
+ */
45
+ declare function eachIterator(elements: unknown, optionalSkipHasOwnPropertyCheck?: boolean): Generator<[unknown, unknown]>;
46
+ /**
47
+ * Loops through each element and calls callback.
48
+ * Callback can return false to break iteration.
49
+ *
50
+ * @param elements - Collection to iterate
51
+ * @param callback - Function called for each element
52
+ * @param optionalSkipHasOwnPropertyCheck - Skip hasOwnProperty check
53
+ * @returns Original elements
54
+ */
55
+ declare function each<T>(elements: T, callback: (value: unknown, key: unknown) => boolean | void, optionalSkipHasOwnPropertyCheck?: boolean): T;
56
+ /**
57
+ * Like each(), except that it expects an async callback.
58
+ *
59
+ * @param elements - Collection to iterate
60
+ * @param asyncCallback - Async function called for each element
61
+ * @param parallelCount - Number of parallel executions (default 1)
62
+ * @param optionalSkipHasOwnPropertyCheck - Skip hasOwnProperty check
63
+ * @returns Promise resolving to original elements
64
+ */
65
+ declare function eachAsync<T>(elements: T, asyncCallback: (value: unknown, key: unknown) => Promise<boolean | void>, parallelCount?: number, optionalSkipHasOwnPropertyCheck?: boolean): Promise<T>;
66
+ /**
67
+ * Returns empty collection matching type of input, plus add function.
68
+ *
69
+ * @param elements - Source collection to match type
70
+ * @returns [success, emptyCollection, addFunction]
71
+ */
72
+ declare function getEmptySimplifiedCollection(elements: unknown): [boolean, unknown, (value: unknown, index: unknown) => void];
73
+ /**
74
+ * Filters collection, returning only elements matching predicate.
75
+ *
76
+ * @param elements - Collection to filter
77
+ * @param callback - Predicate function (truthy = keep)
78
+ * @param optionalSkipHasOwnPropertyCheck - Skip hasOwnProperty
79
+ * @returns Filtered collection (same type as input)
80
+ */
81
+ declare function filter(elements: unknown, callback?: (value: unknown, index: unknown) => boolean, optionalSkipHasOwnPropertyCheck?: boolean): unknown;
82
+ /**
83
+ * Maps collection, transforming each element.
84
+ *
85
+ * @param elements - Collection to map
86
+ * @param callback - Transform function
87
+ * @param optionalSkipHasOwnPropertyCheck - Skip hasOwnProperty
88
+ * @returns Mapped collection (same type as input)
89
+ */
90
+ declare function map(elements: unknown, callback?: (value: unknown, index: unknown) => unknown, optionalSkipHasOwnPropertyCheck?: boolean): unknown;
91
+ /**
92
+ * Maps collection to array.
93
+ *
94
+ * @param elements - Collection to map
95
+ * @param callback - Transform function
96
+ * @param optionalSkipHasOwnPropertyCheck - Skip hasOwnProperty
97
+ * @returns Array of transformed values
98
+ */
99
+ declare function mapToArray<T = unknown>(elements: unknown, callback?: (value: unknown, index: unknown) => T, optionalSkipHasOwnPropertyCheck?: boolean): T[];
100
+ /**
101
+ * Sorts keys by comparing values with comparator.
102
+ *
103
+ * @param elements - Collection to get keys from
104
+ * @param comparator - Comparison function
105
+ * @param optionalSkipHasOwnPropertyCheck - Skip hasOwnProperty
106
+ * @returns Sorted array of keys
107
+ */
108
+ declare function sortKeys(elements: unknown, comparator: (a: unknown, b: unknown) => number, optionalSkipHasOwnPropertyCheck?: boolean): unknown[];
109
+ /**
110
+ * Gets value at index/key from collection.
111
+ *
112
+ * @param elements - Collection
113
+ * @param index - Key or index
114
+ * @param optionalSkipHasOwnPropertyCheck - Skip hasOwnProperty
115
+ * @returns Value at index, or undefined
116
+ */
117
+ declare function getValueAtIndex(elements: unknown, index: unknown, optionalSkipHasOwnPropertyCheck?: boolean): unknown;
118
+ /**
119
+ * Flattens nested arrays to single level (like Array.flat(Infinity)).
120
+ *
121
+ * @param array - Array to flatten
122
+ * @returns Flattened array
123
+ */
124
+ declare function flattenArray(array: unknown): unknown[];
125
+ /**
126
+ * Flattens any collection (arrays, Sets, Maps, objects) to single array.
127
+ *
128
+ * @param elements - Collection to flatten
129
+ * @param optionalSkipHasOwnPropertyCheck - Skip hasOwnProperty
130
+ * @returns Flattened array
131
+ */
132
+ declare function flattenToArray(elements: unknown, optionalSkipHasOwnPropertyCheck?: boolean): unknown[];
133
+ /**
134
+ * Maps and sorts collection to array.
135
+ *
136
+ * @param elements - Collection to process
137
+ * @param comparator - Sort comparison function
138
+ * @param callback - Optional transform
139
+ * @param optionalSkipHasOwnPropertyCheck - Skip hasOwnProperty
140
+ * @returns Sorted array
141
+ */
142
+ declare function mapToArraySorted(elements: unknown, comparator: (a: unknown, b: unknown) => number, callback?: (value: unknown, key: unknown) => unknown, optionalSkipHasOwnPropertyCheck?: boolean): unknown[];
143
+ /**
144
+ * Generic comparison function for sorting.
145
+ *
146
+ * @param a - First value
147
+ * @param b - Second value
148
+ * @returns -1 if a < b, 1 if a > b, 0 if equal
149
+ */
150
+ declare function compare(a: unknown, b: unknown): number;
151
+ /**
152
+ * Compares two numbers (for sorting).
153
+ *
154
+ * @param a - First number
155
+ * @param b - Second number
156
+ * @returns Difference (a - b)
157
+ */
158
+ declare function compareNumbers(a: number, b: number): number;
159
+ /**
160
+ * Compares two numeric strings (like version numbers).
161
+ * Splits on '.', compares each part numerically considering length.
162
+ *
163
+ * @param a - First numeric string
164
+ * @param b - Second numeric string
165
+ * @returns Comparison result
166
+ */
167
+ declare function compareNumericStrings(a: string | number, b: string | number): number;
168
+ /**
169
+ * Natural string comparison (numbers in strings compared numerically).
170
+ * "file5.txt" sorts before "file10.txt".
171
+ *
172
+ * @param a - First string
173
+ * @param b - Second string
174
+ * @returns Comparison result
175
+ */
176
+ declare function compareNaturalStrings(a: string, b: string): number;
177
+ /**
178
+ * Checks if object is empty (no own properties).
179
+ *
180
+ * @param obj - Object to check
181
+ * @param optionalSkipHasOwnPropertyCheck - Skip hasOwnProperty
182
+ * @returns true if empty
183
+ */
184
+ declare function isEmptyObject(obj: unknown, optionalSkipHasOwnPropertyCheck?: boolean): boolean;
185
+ /**
186
+ * Counts own properties in object.
187
+ *
188
+ * @param obj - Object to count
189
+ * @param optionalSkipHasOwnPropertyCheck - Skip hasOwnProperty
190
+ * @returns Number of own properties
191
+ */
192
+ declare function getObjectFieldsCount(obj: unknown, optionalSkipHasOwnPropertyCheck?: boolean): number;
193
+ /**
194
+ * Capitalizes first character of string.
195
+ *
196
+ * @param string - String to capitalize
197
+ * @returns Capitalized string
198
+ */
199
+ declare function capitalize(string: unknown): string;
200
+ /**
201
+ * Checks if string ends with any of the given suffixes.
202
+ *
203
+ * @param string - String to check
204
+ * @param endingCharsStringOrArray - String of chars or array of suffixes
205
+ * @returns true if ends with any
206
+ */
207
+ declare function endsWithAny(string: unknown, endingCharsStringOrArray: string | string[]): boolean;
208
+ /**
209
+ * Checks if string starts with any of the given prefixes.
210
+ *
211
+ * @param string - String to check
212
+ * @param startingCharsStringOrArray - String of chars or array of prefixes
213
+ * @returns true if starts with any
214
+ */
215
+ declare function startsWithAny(string: unknown, startingCharsStringOrArray: string | string[]): boolean;
216
+ /**
217
+ * Trims specific characters from end of string.
218
+ *
219
+ * @param string - String to trim
220
+ * @param trimCharsStringOrArray - Characters to remove
221
+ * @returns Trimmed string
222
+ */
223
+ declare function trimEnd(string: unknown, trimCharsStringOrArray: string | string[]): string;
224
+ /**
225
+ * Trims specific characters from start of string.
226
+ *
227
+ * @param string - String to trim
228
+ * @param trimCharsStringOrArray - Characters to remove
229
+ * @returns Trimmed string
230
+ */
231
+ declare function trimStart(string: unknown, trimCharsStringOrArray: string | string[]): string;
232
+ /**
233
+ * Trims specific characters from both ends of string.
234
+ *
235
+ * @param string - String to trim
236
+ * @param trimCharsStringOrArray - Characters to remove
237
+ * @returns Trimmed string
238
+ */
239
+ declare function trim(string: unknown, trimCharsStringOrArray: string | string[]): string;
240
+ /**
241
+ * Checks if collection contains value (string comparison).
242
+ *
243
+ * @param array - Collection to search
244
+ * @param value - Value to find
245
+ * @returns true if found
246
+ */
247
+ declare function contains(array: unknown, value: unknown): boolean;
248
+ /**
249
+ * Checks if collection contains value (case-insensitive).
250
+ *
251
+ * @param array - Collection to search
252
+ * @param value - Value to find
253
+ * @returns true if found
254
+ */
255
+ declare function containsCaseInsensitive(array: unknown, value: unknown): boolean;
256
+ /**
257
+ * Checks if collection contains all given values.
258
+ *
259
+ * @param array - Collection to search
260
+ * @param values - Values to find
261
+ * @returns true if all found
262
+ */
263
+ declare function containsAll(array: unknown, values: unknown): boolean;
264
+ /**
265
+ * Checks if collection contains any of given values.
266
+ *
267
+ * @param array - Collection to search
268
+ * @param values - Values to find
269
+ * @returns true if any found
270
+ */
271
+ declare function containsAny(array: unknown, values: unknown): boolean;
272
+ /**
273
+ * Checks if collection contains none of given values.
274
+ *
275
+ * @param array - Collection to search
276
+ * @param values - Values to check
277
+ * @returns true if none found
278
+ */
279
+ declare function containsNone(array: unknown, values: unknown): boolean;
280
+ /**
281
+ * Finds first element matching predicate, returns {index, value}.
282
+ *
283
+ * @param elements - Collection to search
284
+ * @param callback - Predicate function
285
+ * @param optionalSkipHasOwnPropertyCheck - Skip hasOwnProperty
286
+ * @returns {index, value} or null
287
+ */
288
+ declare function findIndexValue(elements: unknown, callback: (value: unknown, index: unknown) => boolean, optionalSkipHasOwnPropertyCheck?: boolean): {
289
+ index: unknown;
290
+ value: unknown;
291
+ } | null;
292
+ /**
293
+ * Finds first element matching predicate, returns index.
294
+ *
295
+ * @param elements - Collection to search
296
+ * @param callback - Predicate function
297
+ * @param optionalSkipHasOwnPropertyCheck - Skip hasOwnProperty
298
+ * @returns Index/key or null
299
+ */
300
+ declare function findIndex(elements: unknown, callback: (value: unknown, index: unknown) => boolean, optionalSkipHasOwnPropertyCheck?: boolean): unknown;
301
+ /**
302
+ * Finds first element matching predicate, returns value.
303
+ *
304
+ * @param elements - Collection to search
305
+ * @param callback - Predicate function
306
+ * @param optionalSkipHasOwnPropertyCheck - Skip hasOwnProperty
307
+ * @returns Value or null
308
+ */
309
+ declare function find(elements: unknown, callback: (value: unknown, index: unknown) => boolean, optionalSkipHasOwnPropertyCheck?: boolean): unknown;
310
+ /**
311
+ * Generates a base64 string (with +/ replaced by -_) that is guaranteed to be unique.
312
+ *
313
+ * @returns Unique ID string
314
+ */
315
+ declare const uniqueId: () => string;
316
+ /**
317
+ * Generates a base64 string (with +/ replaced by -_) of the current time.
318
+ *
319
+ * @param now - Optional time to use
320
+ * @returns Timestamp string
321
+ */
322
+ declare const timestamp: (now?: number | null) => string;
323
+ /**
324
+ * Checks if value is a generator function.
325
+ *
326
+ * @param value - Value to check
327
+ * @returns true if generator, false otherwise
328
+ */
329
+ declare const isGeneratorFunction: (value: unknown) => boolean;
330
+ /**
331
+ * Environment-safe btoa.
332
+ *
333
+ * @param str - String to encode
334
+ * @returns Base64 string
335
+ */
336
+ declare function btoa(str: string): string;
337
+ /**
338
+ * Environment-safe atob.
339
+ *
340
+ * @param str - Base64 string to decode
341
+ * @returns Decoded string
342
+ */
343
+ declare function atob(str: string): string;
344
+ /**
345
+ * Encodes a UTF-8 string into a base64 string.
346
+ *
347
+ * @param string - UTF-8 string
348
+ * @returns Base64 string
349
+ */
350
+ declare function utf8ToBase64(string: string): string;
351
+ /**
352
+ * Decodes a base64 string back into a UTF-8 string.
353
+ *
354
+ * @param base64string - Base64 string
355
+ * @returns Decoded UTF-8 string
356
+ */
357
+ declare function base64ToUtf8(base64string: string): string;
358
+ /**
359
+ * Converts a base64 string into a hex string.
360
+ *
361
+ * @param base64string - Base64 string
362
+ * @returns Hex string
363
+ */
364
+ declare function base64ToHex(base64string: string): string;
365
+ /**
366
+ * Converts a hex string into a base64 string.
367
+ *
368
+ * @param hexstring - Hex string
369
+ * @returns Base64 string
370
+ */
371
+ declare function hexToBase64(hexstring: string): string;
372
+ /**
373
+ * Converts a base64 string into bytes (Uint8Array).
374
+ *
375
+ * @param base64string - Base64 string
376
+ * @returns Bytes
377
+ */
378
+ declare function base64ToBytes(base64string: string): Uint8Array;
379
+ /**
380
+ * Converts bytes into a base64 string.
381
+ *
382
+ * @param arraybuffer - Bytes source
383
+ * @returns Base64 string
384
+ */
385
+ declare function bytesToBase64(arraybuffer: ArrayLike<number> | ArrayBuffer): string;
386
+ /**
387
+ * Executes callback after ms. Delta time in seconds passed to callback.
388
+ *
389
+ * @param callback - Function to call
390
+ * @param ms - Milliseconds to wait
391
+ * @returns Handler with remove() method
392
+ */
393
+ declare function setTimeout(callback: (deltaTime: number) => unknown, ms: number): {
394
+ remove: () => void;
395
+ };
396
+ /**
397
+ * Executes callback every intervalMs. Delta time in seconds passed to callback.
398
+ *
399
+ * @param callback - Function to call
400
+ * @param intervalMs - Interval in milliseconds
401
+ * @param fireImmediately - Whether to call immediately
402
+ * @returns Handler with remove() method
403
+ */
404
+ declare function setInterval(callback: (deltaTime: number) => unknown, intervalMs?: number, fireImmediately?: boolean): {
405
+ remove: () => void;
406
+ };
407
+ /**
408
+ * Executes callback after frames. Delta time in seconds passed to callback.
409
+ *
410
+ * @param callback - Function to call
411
+ * @param frames - Number of frames to wait
412
+ * @returns Handler with remove() method
413
+ */
414
+ declare function setAnimationFrameTimeout(callback: (deltaTime: number) => unknown, frames?: number): {
415
+ remove: () => void;
416
+ };
417
+ /**
418
+ * Executes callback every intervalFrames. Delta time in seconds passed to callback.
419
+ *
420
+ * @param callback - Function to call
421
+ * @param intervalFrames - Interval in frames
422
+ * @param fireImmediately - Whether to call immediately
423
+ * @returns Handler with remove() method
424
+ */
425
+ declare function setAnimationFrameInterval(callback: (deltaTime: number) => unknown, intervalFrames?: number, fireImmediately?: boolean): {
426
+ remove: () => void;
427
+ };
428
+ /**
429
+ * Returns a promise resolved after ms.
430
+ *
431
+ * @param ms - Milliseconds to wait
432
+ * @returns Promise resolving to delta time
433
+ */
434
+ declare function promiseTimeout(ms: number): Promise<number>;
435
+ /**
436
+ * Returns a promise resolved after frames.
437
+ *
438
+ * @param frames - Number of frames to wait
439
+ * @returns Promise resolving to delta time
440
+ */
441
+ declare function promiseAnimationFrameTimeout(frames: number): Promise<number>;
442
+ /**
443
+ * Fetch with retry and abort functionality.
444
+ *
445
+ * @param url - URL to fetch
446
+ * @param options - Fetch options including retries and delay
447
+ * @returns Object with then(), catch(), finally(), remove(), isRemoved()
448
+ */
449
+ declare function fetch(url: string, options?: unknown): {
450
+ then: (onfulfilled?: (value: Response) => unknown, onrejected?: (reason: unknown) => unknown) => unknown;
451
+ catch: (onrejected?: (reason: unknown) => unknown) => unknown;
452
+ finally: (onfinally?: () => unknown) => unknown;
453
+ remove: () => unknown;
454
+ isRemoved: () => boolean;
455
+ };
456
+ /**
457
+ * Cached version of fetch.
458
+ *
459
+ * @param url - URL to fetch
460
+ * @param options - Fetch options
461
+ * @param responseFunction - Optional function to process response before caching
462
+ * @returns Promise resolving to data
463
+ */
464
+ declare const cachedFetch: (url: string, options?: unknown, responseFunction?: (response: Response) => unknown) => Promise<unknown>;
465
+ /**
466
+ * Creates a new transactional value.
467
+ *
468
+ * @param value - Initial value
469
+ * @returns Transactional value object
470
+ */
471
+ declare function createTransactionalValue(value?: unknown): TransactionalValue;
472
+ /**
473
+ * Validates a transactional value structure.
474
+ *
475
+ * @param transactionalValue - Value to check
476
+ * @returns true if valid
477
+ */
478
+ declare function isTransactionalValueValid(transactionalValue: unknown): transactionalValue is TransactionalValue;
479
+ /**
480
+ * Converts transactional value to string representation of its state.
481
+ *
482
+ * @param transactionalValue - Transactional value
483
+ * @returns State string
484
+ */
485
+ declare function transactionalValueToString(transactionalValue: unknown): string;
486
+ /**
487
+ * Sets and commits a value, clearing all uncommitted changes.
488
+ *
489
+ * @param transactionalValue - Transactional value
490
+ * @param value - New value
491
+ */
492
+ declare function transactionSetAndCommit(transactionalValue: TransactionalValue, value: unknown): void;
493
+ /**
494
+ * Adds an uncommitted change. Returns change ID.
495
+ *
496
+ * @param transactionalValue - Transactional value
497
+ * @param value - New value
498
+ * @returns Change ID
499
+ */
500
+ declare function transactionSetWithoutCommitting(transactionalValue: TransactionalValue, value: unknown): string;
501
+ /**
502
+ * Commits a specific change by ID.
503
+ *
504
+ * @param transactionalValue - Transactional value
505
+ * @param changeId - Change ID
506
+ * @returns true if committed
507
+ */
508
+ declare function transactionCommitChange(transactionalValue: TransactionalValue, changeId: string): boolean;
509
+ /**
510
+ * Cancels a specific change by ID.
511
+ *
512
+ * @param transactionalValue - Transactional value
513
+ * @param changeId - Change ID
514
+ * @returns true if cancelled
515
+ */
516
+ declare function transactionCancelChange(transactionalValue: TransactionalValue, changeId: string): boolean;
517
+ /**
518
+ * Checks if a change is still relevant.
519
+ *
520
+ * @param transactionalValue - Transactional value
521
+ * @param changeId - Change ID
522
+ * @returns true if relevant
523
+ */
524
+ declare function transactionIsChangeRelevant(transactionalValue: TransactionalValue, changeId: string): boolean;
525
+ /**
526
+ * Gets current committed value.
527
+ *
528
+ * @param transactionalValue - Transactional value
529
+ * @returns Committed value
530
+ */
531
+ declare function transactionGetCommittedValue(transactionalValue: TransactionalValue): unknown;
532
+ /**
533
+ * Gets current value (including most recent uncommitted change).
534
+ *
535
+ * @param transactionalValue - Transactional value
536
+ * @returns Current value
537
+ */
538
+ declare function transactionGetValue(transactionalValue: TransactionalValue): unknown;
539
+ /**
540
+ * Performs a deep equality comparison between two collections, sorting on keys first.
541
+ *
542
+ * @param elementsA - First collection
543
+ * @param elementsB - Second collection
544
+ * @param ignoreKeys - Keys to ignore
545
+ * @returns true if equivalent
546
+ */
547
+ declare function equalsMapLike(elementsA: unknown, elementsB: unknown, ignoreKeys?: string | string[]): boolean;
548
+ /**
549
+ * Executes callback when document is ready.
550
+ *
551
+ * @param callback - Function to call
552
+ * @returns Handler with remove() method
553
+ */
554
+ declare function onDomReady(callback: () => void): {
555
+ remove: () => void;
556
+ };
557
+ /**
558
+ * Parses version string into object with comparison helpers.
559
+ *
560
+ * @param version - Version string or object
561
+ * @returns Version object with comparison methods
562
+ */
563
+ declare function parseVersionString(version: unknown): {
564
+ major: number;
565
+ minor: number;
566
+ patch: number;
567
+ toString: () => string;
568
+ equals: (other: unknown) => boolean;
569
+ largerThan: (other: unknown) => boolean;
570
+ largerThanOrEquals: (other: unknown) => boolean;
571
+ smallerThan: (other: unknown) => boolean;
572
+ smallerThanOrEquals: (other: unknown) => boolean;
573
+ };
574
+ /**
575
+ * Increases numeric string by 1 without limit.
576
+ *
577
+ * @param str - Numeric string
578
+ * @returns Increased string
579
+ */
580
+ declare function increaseNumericStringByOne(str: string): string;
581
+ /**
582
+ * Checks if collection contains all given values (case-insensitive).
583
+ *
584
+ * @param array - Collection to search
585
+ * @param values - Values to find
586
+ * @returns true if all found
587
+ */
588
+ declare function containsAllCaseInsensitive(array: unknown, values: unknown): boolean;
589
+ /**
590
+ * Checks if collection contains any of given values (case-insensitive).
591
+ *
592
+ * @param array - Collection to search
593
+ * @param values - Values to find
594
+ * @returns true if any found
595
+ */
596
+ declare function containsAnyCaseInsensitive(array: unknown, values: unknown): boolean;
597
+ /**
598
+ * Checks if collection contains none of given values (case-insensitive).
599
+ *
600
+ * @param array - Collection to search
601
+ * @param values - Values to find
602
+ * @returns true if none found
603
+ */
604
+ declare function containsNoneCaseInsensitive(array: unknown, values: unknown): boolean;
605
+ /**
606
+ * Returns string with start/end trimmed and ensures valid sentence ending.
607
+ *
608
+ * @param sentence - String to purge
609
+ * @returns Purged sentence
610
+ */
611
+ declare function purgeSentence(sentence: unknown): string;
612
+ /**
613
+ * Obtains error message from any input.
614
+ *
615
+ * @param error - Error source
616
+ * @returns Error message string
617
+ */
618
+ declare function purgeErrorMessage(error: unknown): string;
619
+ /**
620
+ * Generates permutations of names (e.g. foobar, fooBar, FooBar, foo-bar, foo_bar).
621
+ *
622
+ * @param names - Parts to combine
623
+ * @returns Array of permutations
624
+ */
625
+ declare function generateNamePermutations(...names: unknown[]): string[];
626
+ /**
627
+ * Compares two strings generated by LeUtils.timestamp(). Primarily used for sorting.
628
+ */
629
+ declare function compareTimestampStrings(a: string | null, b: string | null): number;
630
+ /**
631
+ * Returns true if the user is on a smartphone device (mobile).
632
+ */
633
+ declare function platformIsMobile(): boolean;
634
+ /**
635
+ * Returns true if the user has a cursor (mouse).
636
+ */
637
+ declare function platformHasCursor(): boolean;
638
+ /**
639
+ * Returns string with email purged (lowercased, trimmed).
640
+ */
641
+ declare function purgeEmail(email: unknown): string;
642
+ /**
643
+ * Returns true if the focus is effectively clear, meaning that the user is not typing in an input field.
644
+ */
645
+ declare const isFocusClear: () => boolean;
646
+ /**
647
+ * Returns the user's locale. Returns 'en-US' if it can't be determined.
648
+ */
649
+ declare const getUserLocale: () => string;
650
+ /**
651
+ * Returns the user's locale date format. Always returns YYYY MM DD, with the character in between depending on the user's locale. Returns 'YYYY/MM/DD' if the user's locale can't be determined.
652
+ */
653
+ declare const getUserLocaleDateFormat: () => string;
654
+ /**
655
+ * Returns an empty 1x1 transparent image data URL.
656
+ */
657
+ declare function getEmptyImageSrc(): string;
658
+ /**
659
+ * Calculates and returns the percentage of the part and total ((part / total) * 100).
660
+ */
661
+ declare function getPercentage(part: number | string, total: number | string): number;
662
+ /**
663
+ * Returns the pixels of the given Image object.
664
+ */
665
+ declare function getImagePixels(image: HTMLImageElement): Promise<Uint8ClampedArray>;
666
+ /**
667
+ * Returns the data URL (mimetype "image/png") of a colored version of the given Image object.
668
+ */
669
+ declare function getColoredImage(image: HTMLImageElement, color: string): Promise<string>;
670
+ /**
671
+ * Returns the hex color of the given RGB(A).
672
+ */
673
+ declare function rgbToHex(rgb: number[]): string;
674
+ /**
675
+ * Returns the RGB(A) of the given hex color.
676
+ */
677
+ declare function hexToRgb(hexstring: string): number[];
678
+ /**
679
+ * Returns the HSL(A) of the given RGB(A).
680
+ */
681
+ declare function rgbToHsl(rgb: number[]): number[];
682
+ /**
683
+ * Returns the RGB(A) of the given HSL(A).
684
+ */
685
+ declare const hslToRgb: (hsl: number[]) => number[];
686
+ /**
687
+ * Returns the LAB(A) of the given RGB(A).
688
+ */
689
+ declare function rgbToLab(rgb: number[]): number[];
690
+ /**
691
+ * Returns the difference (calculated with DeltaE) of the LAB values of the given RGB values.
692
+ */
693
+ declare function getDifferenceBetweenRgb(rgbA: number[], rgbB: number[]): number;
694
+ /**
695
+ * Returns the difference (calculated with DeltaE) of the given LAB values.
696
+ */
697
+ declare function getDifferenceBetweenLab(labA: number[], labB: number[]): number;
698
+ /**
699
+ * Returns the RGB(A) between the two given RGB(A) values, based on the given percentage (0-100).
700
+ */
701
+ declare function getRgbBetween(startRgb: number[], endRgb: number[], percentage: number): number[];
702
+ /**
703
+ * Returns the RGB(A) of the given RGB(A) values, based on the given percentage (0-100).
704
+ */
705
+ declare function getRgbOfGradient(gradient: Record<number, number[]>, percentage: number): number[];
706
+ /**
707
+ * Download file from URL or data.
708
+ */
709
+ declare function downloadFile(name: string, data: string | Blob): void;
710
+ /**
711
+ * LocalStorage Get.
712
+ */
713
+ declare function localStorageGet(key: string): string | null;
714
+ /**
715
+ * LocalStorage Set.
716
+ */
717
+ declare function localStorageSet(key: string, value: string): void;
718
+ /**
719
+ * LocalStorage Remove.
720
+ */
721
+ declare function localStorageRemove(key: string): void;
722
+ /**
723
+ * Checks if given host is private.
724
+ */
725
+ declare function isGivenHostPrivate(host: string): boolean;
726
+ /**
727
+ * Checks if current host is private.
728
+ */
729
+ declare function isCurrentHostPrivate(): boolean;
730
+ /**
731
+ * Create worker thread.
732
+ */
733
+ declare function createWorkerThread(name: string): {
734
+ worker: Worker | null;
735
+ sendMessage: (data: unknown, options?: {
736
+ timeout?: number;
737
+ }) => Promise<unknown>;
738
+ };
739
+ /**
740
+ * Send message to worker.
741
+ */
742
+ declare const sendWorkerMessage: (workerName: string, data: unknown, options?: {
743
+ timeout?: number;
744
+ }) => Promise<unknown>;
745
+
746
+ /**
747
+ * LeTypes - Type validation and conversion utilities
748
+ */
749
+ /**
750
+ * Checks if a value is set (not null and not undefined).
751
+ */
752
+ declare function ISSET(value: unknown): boolean;
753
+ /**
754
+ * Converts value to string. Returns empty string if not set.
755
+ */
756
+ declare function STRING(value: unknown): string;
757
+ /**
758
+ * Checks if value is an array.
759
+ */
760
+ declare function IS_ARRAY(value: unknown): value is unknown[];
761
+ /**
762
+ * Ensures value is an array. Wraps in array if not already one.
763
+ */
764
+ declare function ARRAY(value: unknown): unknown[];
765
+ /**
766
+ * Checks if value is an object (and not an array).
767
+ */
768
+ declare function IS_OBJECT(value: unknown): value is Record<string, unknown>;
769
+ /**
770
+ * Ensures value is an object. Returns empty object if not set.
771
+ */
772
+ declare function OBJECT(value: unknown): Record<string, unknown>;
773
+ /**
774
+ * Converts value to number. Returns 0 if NaN.
775
+ */
776
+ declare function FLOAT(value: unknown): number;
777
+ /**
778
+ * Converts value to integer. Returns 0 if NaN.
779
+ */
780
+ declare function INT(value: unknown): number;
781
+ /**
782
+ * Returns first set string among arguments.
783
+ */
784
+ declare function STRING_ANY(...values: unknown[]): string;
785
+ /**
786
+ * Returns first set float among arguments.
787
+ */
788
+ declare function FLOAT_ANY(...values: unknown[]): number;
789
+ /**
790
+ * Returns first set integer among arguments.
791
+ */
792
+ declare function INT_ANY(...values: unknown[]): number;
793
+ /**
794
+ * Converts value to boolean.
795
+ * Matches strings "true", "1", "yes", "on" (case-insensitive).
796
+ */
797
+ declare function BOOL(value: unknown): boolean;
798
+ /**
799
+ * Returns the first non-null non-undefined boolean-castable value as a boolean.
800
+ */
801
+ declare function BOOL_ANY(...values: unknown[]): boolean;
802
+ /**
803
+ * Lax float conversion. Strips non-numeric characters.
804
+ */
805
+ declare function FLOAT_LAX(value: unknown): number;
806
+ /**
807
+ * Lax integer conversion.
808
+ */
809
+ declare function INT_LAX(value: unknown): number;
810
+ /**
811
+ * Returns first set lax float.
812
+ */
813
+ declare function FLOAT_LAX_ANY(...values: unknown[]): number;
814
+ /**
815
+ * Returns first set lax integer.
816
+ */
817
+ declare function INT_LAX_ANY(...values: unknown[]): number;
818
+
819
+ /**
820
+ * A simple event emitter class that allows you to register listeners for events, emit events, and remove listeners.
821
+ */
822
+ declare class EventEmitter {
823
+ #private;
824
+ /**
825
+ * Creates a new EventEmitter instance.
826
+ */
827
+ constructor();
828
+ /**
829
+ * Registers a listener for a specific event.
830
+ *
831
+ * @param {string} event - The name of the event to listen for.
832
+ * @param {Function} listener - The function to call when the event is emitted.
833
+ * @returns {{remove:(()=>void)}}
834
+ */
835
+ on(event: string, listener: (...args: unknown[]) => unknown): {
836
+ remove: () => void;
837
+ };
838
+ /**
839
+ * Registers a listener for a specific event, this listener will be called only once.
840
+ *
841
+ * @param {string} event - The name of the event to listen for.
842
+ * @param {Function} listener - The function to call when the event is emitted.
843
+ * @returns {{remove:()=>void}}
844
+ */
845
+ once(event: string, listener: (...args: unknown[]) => unknown): {
846
+ remove: () => void;
847
+ };
848
+ /**
849
+ * Removes a listener for a specific event.
850
+ *
851
+ * @param {string} event - The name of the event to stop listening for.
852
+ * @param {Function} listener - The function to remove from the event listeners.
853
+ */
854
+ off(event: string, listener: (...args: unknown[]) => unknown): void;
855
+ /**
856
+ * Emits an event, calling all registered listeners with the provided arguments.
857
+ *
858
+ * @param {string} event - The name of the event to emit.
859
+ * @param {...*} args - The arguments to pass to the listeners.
860
+ */
861
+ emit(event: string, ...args: unknown[]): void;
862
+ /**
863
+ * Clears all listeners for a specific event or all events if no event is specified.
864
+ *
865
+ * @param {string} [event] - The name of the event to clear listeners for. If not provided, all events will be cleared.
866
+ */
867
+ clear(event?: string): void;
868
+ }
869
+
870
+ declare class LinkedList<T> {
871
+ #private;
872
+ constructor();
873
+ /**
874
+ * Returns the number of elements in the list.
875
+ *
876
+ * @returns {number}
877
+ */
878
+ get size(): number;
879
+ /**
880
+ * Adds a new value to the beginning of the list.
881
+ *
882
+ * @param {*} value
883
+ */
884
+ unshift(value: T): void;
885
+ /**
886
+ * Adds a new value to the end of the list.
887
+ *
888
+ * @param {*} value
889
+ */
890
+ push(value: T): void;
891
+ /**
892
+ * Removes the first value from the list and returns it.
893
+ *
894
+ * @returns {*|undefined}
895
+ */
896
+ shift(): T | undefined;
897
+ /**
898
+ * Removes the last value from the list and returns it.
899
+ *
900
+ * @returns {*|undefined}
901
+ */
902
+ pop(): T | undefined;
903
+ }
904
+
905
+ /**
906
+ * SerializableMap class extends the native Map to provide a JSON representation.
907
+ *
908
+ * This class can only have string keys, as JSON does not support non-string keys.
909
+ */
910
+ declare class SerializableMap<K, V> extends Map<K, V> {
911
+ /**
912
+ * Returns a JSON representation of the map.
913
+ *
914
+ * @returns {Record<string, V>}
915
+ */
916
+ toJSON(): Record<string, V>;
917
+ }
918
+
919
+ /**
920
+ * A TreeSet is a set of elements, sorted by a comparator.
921
+ * Binary search is used to find elements, which makes it very fast to find elements.
922
+ *
923
+ * The comparator is also used to determine if two values are equal to each other.
924
+ * This way, you can have values that aren't the same be treated as if they are. This can be used to deal with issues such as floating point errors for example.
925
+ */
926
+ declare class TreeSet<T> {
927
+ #private;
928
+ /**
929
+ * Creates a new TreeSet with the given elements and comparator.
930
+ *
931
+ * @param {*[]} [elements=[]] - The initial elements of the set.
932
+ * @param {(valueA:*, valueB:*) => number} [comparator=defaultCompare] - The comparator function to use for sorting.
933
+ */
934
+ constructor(elements?: T[], comparator?: (valueA: T, valueB: T) => number);
935
+ /**
936
+ * @param {*} value - The value to search for in the set.
937
+ * @returns {{found:boolean, index:number, value:*|undefined}} - An object containing whether the value was found, the index where it would be inserted, and the value at that index (if found).
938
+ * @private
939
+ */
940
+ private binarySearch;
941
+ /**
942
+ * Returns the elements of the set.
943
+ */
944
+ getElements(): T[];
945
+ /**
946
+ * Returns the comparator of the set.
947
+ *
948
+ * @returns {(valueA:*, valueB:*) => number}
949
+ */
950
+ getComparator(): (valueA: T, valueB: T) => number;
951
+ /**
952
+ * Returns the size of the set.
953
+ *
954
+ * @returns {number}
955
+ */
956
+ size(): number;
957
+ /**
958
+ * Returns true if the set is empty, false otherwise.
959
+ *
960
+ * @returns {boolean}
961
+ */
962
+ isEmpty(): boolean;
963
+ /**
964
+ * Returns true if the set contains a value that is equal to the given value, returns false otherwise.
965
+ *
966
+ * @param {*} value - The value to check for in the set.
967
+ * @return {boolean} - True if the set contains the value, false otherwise.
968
+ */
969
+ contains(value: T): boolean;
970
+ /**
971
+ * Returns the first element of the set, or undefined if it is empty.
972
+ *
973
+ * @return {*|undefined} - The first element of the set, or undefined if it is empty.
974
+ */
975
+ first(): T | undefined;
976
+ /**
977
+ * Returns the last element of the set, or undefined if it is empty.
978
+ *
979
+ * @return {*|undefined} - The last element of the set, or undefined if it is empty.
980
+ */
981
+ last(): T | undefined;
982
+ /**
983
+ * Removes and returns the first element of the set, or undefined if it is empty.
984
+ *
985
+ * @returns {*|undefined} - The first element of the set, or undefined if it is empty.
986
+ */
987
+ pollFirst(): T | undefined;
988
+ /**
989
+ * Removes and returns the last element of the set, or undefined if it is empty.
990
+ *
991
+ * @returns {*|undefined} - The last element of the set, or undefined if it is empty.
992
+ */
993
+ pollLast(): T | undefined;
994
+ /**
995
+ * Adds the given value to the set. Will only do so if no equal value already exists.
996
+ * @param {*} value - The value to add to the set.
997
+ */
998
+ add(value: T): void;
999
+ /**
1000
+ * Removes the given value from the set.
1001
+ * @param value - The value to remove
1002
+ * @returns true if removed
1003
+ */
1004
+ remove(value: T): boolean;
1005
+ /**
1006
+ * Adds all the given values to the set. Will only do so if no equal value already exists.
1007
+ *
1008
+ * @param {unknown} values - The values to add to the set.
1009
+ */
1010
+ addAll(values: unknown): void;
1011
+ /**
1012
+ * Returns an equal value that's already in the tree set, or undefined if no equal values in it exist.
1013
+ *
1014
+ * @param {*} value - The value to search for in the set.
1015
+ * @return {*|undefined} - The equal value if found, or undefined if not found.
1016
+ */
1017
+ getEqualValue(value: T): T | undefined;
1018
+ /**
1019
+ * Returns an equal value that's already in the tree set. If no equal values in it exist, the given value will be added and returned.
1020
+ *
1021
+ * @param {*} value - The value to search for in the set.
1022
+ * @return {*} - The equal value if found, or the added value if not found.
1023
+ */
1024
+ getEqualValueOrAdd(value: T): T;
1025
+ /**
1026
+ * Returns a string representation of the TreeSet.
1027
+ *
1028
+ * @returns {string} - A string representation of the TreeSet, including its elements and comparator.
1029
+ */
1030
+ toString(): string;
1031
+ /**
1032
+ * Returns a JSON representation of the TreeSet.
1033
+ *
1034
+ * @returns {Object} - An object containing the elements and comparator of the TreeSet.
1035
+ */
1036
+ toJSON(): {
1037
+ elements: T[];
1038
+ comparator: string;
1039
+ };
1040
+ }
1041
+
1042
+ declare const LeUtils: {
9
1043
  equals(a: unknown, b: unknown): boolean;
10
1044
  clone<T>(value: T): T;
11
1045
  supportsEach(elements: unknown): boolean;
@@ -73,16 +1107,16 @@ export declare const LeUtils: {
73
1107
  remove: () => unknown;
74
1108
  isRemoved: () => boolean;
75
1109
  };
76
- createTransactionalValue(value?: unknown): LeUtilsFunctions.TransactionalValue;
77
- isTransactionalValueValid(transactionalValue: unknown): transactionalValue is LeUtilsFunctions.TransactionalValue;
1110
+ createTransactionalValue(value?: unknown): TransactionalValue;
1111
+ isTransactionalValueValid(transactionalValue: unknown): transactionalValue is TransactionalValue;
78
1112
  transactionalValueToString(transactionalValue: unknown): string;
79
- transactionSetAndCommit(transactionalValue: LeUtilsFunctions.TransactionalValue, value: unknown): void;
80
- transactionSetWithoutCommitting(transactionalValue: LeUtilsFunctions.TransactionalValue, value: unknown): string;
81
- transactionCommitChange(transactionalValue: LeUtilsFunctions.TransactionalValue, changeId: string): boolean;
82
- transactionCancelChange(transactionalValue: LeUtilsFunctions.TransactionalValue, changeId: string): boolean;
83
- transactionIsChangeRelevant(transactionalValue: LeUtilsFunctions.TransactionalValue, changeId: string): boolean;
84
- transactionGetCommittedValue(transactionalValue: LeUtilsFunctions.TransactionalValue): unknown;
85
- transactionGetValue(transactionalValue: LeUtilsFunctions.TransactionalValue): unknown;
1113
+ transactionSetAndCommit(transactionalValue: TransactionalValue, value: unknown): void;
1114
+ transactionSetWithoutCommitting(transactionalValue: TransactionalValue, value: unknown): string;
1115
+ transactionCommitChange(transactionalValue: TransactionalValue, changeId: string): boolean;
1116
+ transactionCancelChange(transactionalValue: TransactionalValue, changeId: string): boolean;
1117
+ transactionIsChangeRelevant(transactionalValue: TransactionalValue, changeId: string): boolean;
1118
+ transactionGetCommittedValue(transactionalValue: TransactionalValue): unknown;
1119
+ transactionGetValue(transactionalValue: TransactionalValue): unknown;
86
1120
  equalsMapLike(elementsA: unknown, elementsB: unknown, ignoreKeys?: string | string[]): boolean;
87
1121
  onDomReady(callback: () => void): {
88
1122
  remove: () => void;
@@ -145,4 +1179,5 @@ export declare const LeUtils: {
145
1179
  timeout?: number;
146
1180
  }) => Promise<unknown>;
147
1181
  };
148
- //# sourceMappingURL=index.d.ts.map
1182
+
1183
+ export { ARRAY, BOOL, BOOL_ANY, EventEmitter, FLOAT, FLOAT_ANY, FLOAT_LAX, FLOAT_LAX_ANY, INT, INT_ANY, INT_LAX, INT_LAX_ANY, ISSET, IS_ARRAY, IS_OBJECT, LeUtils, LinkedList, OBJECT, STRING, STRING_ANY, SerializableMap, type TransactionChange, type TransactionalValue, TreeSet, atob, base64ToBytes, base64ToHex, base64ToUtf8, btoa, bytesToBase64, cachedFetch, capitalize, clone, compare, compareNaturalStrings, compareNumbers, compareNumericStrings, compareTimestampStrings, contains, containsAll, containsAllCaseInsensitive, containsAny, containsAnyCaseInsensitive, containsCaseInsensitive, containsNone, containsNoneCaseInsensitive, createTransactionalValue, createWorkerThread, downloadFile, each, eachAsync, eachIterator, endsWithAny, equals, equalsMapLike, fetch, filter, find, findIndex, findIndexValue, flattenArray, flattenToArray, generateNamePermutations, getColoredImage, getDifferenceBetweenLab, getDifferenceBetweenRgb, getEmptyImageSrc, getEmptySimplifiedCollection, getImagePixels, getObjectFieldsCount, getPercentage, getRgbBetween, getRgbOfGradient, getUserLocale, getUserLocaleDateFormat, getValueAtIndex, hexToBase64, hexToRgb, hslToRgb, increaseNumericStringByOne, isCurrentHostPrivate, isEmptyObject, isFocusClear, isGeneratorFunction, isGivenHostPrivate, isTransactionalValueValid, localStorageGet, localStorageRemove, localStorageSet, map, mapToArray, mapToArraySorted, onDomReady, parseVersionString, platformHasCursor, platformIsMobile, promiseAnimationFrameTimeout, promiseTimeout, purgeEmail, purgeErrorMessage, purgeSentence, rgbToHex, rgbToHsl, rgbToLab, sendWorkerMessage, setAnimationFrameInterval, setAnimationFrameTimeout, setInterval, setTimeout, sortKeys, startsWithAny, supportsEach, timestamp, transactionCancelChange, transactionCommitChange, transactionGetCommittedValue, transactionGetValue, transactionIsChangeRelevant, transactionSetAndCommit, transactionSetWithoutCommitting, transactionalValueToString, trim, trimEnd, trimStart, uniqueId, utf8ToBase64 };