@lowentry/utils 2.0.2 → 2.0.4

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.
@@ -0,0 +1,745 @@
1
+ /**
2
+ * LeUtils - Core utility functions
3
+ */
4
+ /**
5
+ * Transactional Value Types
6
+ */
7
+ export interface TransactionChange {
8
+ id: string;
9
+ value: unknown;
10
+ }
11
+ export 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
+ export 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
+ export 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
+ export 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
+ export 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
+ export 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
+ export 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
+ export 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
+ export 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
+ export 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
+ export 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
+ export 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
+ export 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
+ export 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
+ export 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
+ export 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
+ export 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
+ export 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
+ export 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
+ export 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
+ export 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
+ export 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
+ export 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
+ export 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
+ export 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
+ export 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
+ export 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
+ export 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
+ export 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
+ export 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
+ export 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
+ export 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
+ export 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
+ export 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
+ export 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
+ export 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
+ export 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
+ export 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
+ export declare const isGeneratorFunction: (value: unknown) => boolean;
330
+ /**
331
+ * Environment-safe btoa.
332
+ *
333
+ * @param str - String to encode
334
+ * @returns Base64 string
335
+ */
336
+ export 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
+ export 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
+ export 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
+ export 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
+ export 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
+ export 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
+ export 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
+ export 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
+ export 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
+ export 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
+ export 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
+ export 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
+ export 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
+ export 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
+ export 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
+ export 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
+ export 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
+ export 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
+ export 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
+ export 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
+ export 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
+ export 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
+ export 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
+ export 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
+ export 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
+ export 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
+ export 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
+ export 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
+ export 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
+ export 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
+ export 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
+ export 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
+ export 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
+ export 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
+ export 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
+ export declare function generateNamePermutations(...names: unknown[]): string[];
626
+ /**
627
+ * Compares two strings generated by LeUtils.timestamp(). Primarily used for sorting.
628
+ */
629
+ export 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
+ export declare function platformIsMobile(): boolean;
634
+ /**
635
+ * Returns true if the user has a cursor (mouse).
636
+ */
637
+ export declare function platformHasCursor(): boolean;
638
+ /**
639
+ * Returns string with email purged (lowercased, trimmed).
640
+ */
641
+ export 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
+ export declare const isFocusClear: () => boolean;
646
+ /**
647
+ * Returns the user's locale. Returns 'en-US' if it can't be determined.
648
+ */
649
+ export 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
+ export declare const getUserLocaleDateFormat: () => string;
654
+ /**
655
+ * Returns an empty 1x1 transparent image data URL.
656
+ */
657
+ export declare function getEmptyImageSrc(): string;
658
+ /**
659
+ * Calculates and returns the percentage of the part and total ((part / total) * 100).
660
+ */
661
+ export declare function getPercentage(part: number | string, total: number | string): number;
662
+ /**
663
+ * Returns the pixels of the given Image object.
664
+ */
665
+ export 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
+ export declare function getColoredImage(image: HTMLImageElement, color: string): Promise<string>;
670
+ /**
671
+ * Returns the hex color of the given RGB(A).
672
+ */
673
+ export declare function rgbToHex(rgb: number[]): string;
674
+ /**
675
+ * Returns the RGB(A) of the given hex color.
676
+ */
677
+ export declare function hexToRgb(hexstring: string): number[];
678
+ /**
679
+ * Returns the HSL(A) of the given RGB(A).
680
+ */
681
+ export declare function rgbToHsl(rgb: number[]): number[];
682
+ /**
683
+ * Returns the RGB(A) of the given HSL(A).
684
+ */
685
+ export declare const hslToRgb: (hsl: number[]) => number[];
686
+ /**
687
+ * Returns the LAB(A) of the given RGB(A).
688
+ */
689
+ export 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
+ export declare function getDifferenceBetweenRgb(rgbA: number[], rgbB: number[]): number;
694
+ /**
695
+ * Returns the difference (calculated with DeltaE) of the given LAB values.
696
+ */
697
+ export 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
+ export 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
+ export declare function getRgbOfGradient(gradient: Record<number, number[]>, percentage: number): number[];
706
+ /**
707
+ * Download file from URL or data.
708
+ */
709
+ export declare function downloadFile(name: string, data: string | Blob): void;
710
+ /**
711
+ * LocalStorage Get.
712
+ */
713
+ export declare function localStorageGet(key: string): string | null;
714
+ /**
715
+ * LocalStorage Set.
716
+ */
717
+ export declare function localStorageSet(key: string, value: string): void;
718
+ /**
719
+ * LocalStorage Remove.
720
+ */
721
+ export declare function localStorageRemove(key: string): void;
722
+ /**
723
+ * Checks if given host is private.
724
+ */
725
+ export declare function isGivenHostPrivate(host: string): boolean;
726
+ /**
727
+ * Checks if current host is private.
728
+ */
729
+ export declare function isCurrentHostPrivate(): boolean;
730
+ /**
731
+ * Create worker thread.
732
+ */
733
+ export 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
+ export declare const sendWorkerMessage: (workerName: string, data: unknown, options?: {
743
+ timeout?: number;
744
+ }) => Promise<unknown>;
745
+ //# sourceMappingURL=LeUtils.d.ts.map