@andrew_l/toolkit 0.0.1 → 0.2.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.
package/dist/index.d.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  import * as lodash from 'lodash';
2
2
 
3
3
  type ItemType<T> = T extends Array<infer X> ? X : T extends string ? string : Exclude<T, null | undefined>;
4
+ type ArrayableValue<T> = T extends object ? Readonly<T> : T;
4
5
  /**
5
6
  * Converts a value into an array. This function handles different types of input,
6
7
  * converting them to arrays as follows:
@@ -21,7 +22,7 @@ type ItemType<T> = T extends Array<infer X> ? X : T extends string ? string : Ex
21
22
  *
22
23
  * @group Array
23
24
  */
24
- declare function arrayable<T>(value: Readonly<T>): ItemType<T>[];
25
+ declare function arrayable<T>(value: ArrayableValue<T>): ItemType<T>[];
25
26
 
26
27
  /**
27
28
  * Calculates the average value from an array of numbers.
@@ -94,6 +95,42 @@ declare function chunk<T>(list: readonly T[], size?: number): T[][];
94
95
  */
95
96
  declare function chunkSeries(list: number[], step?: number): number[][];
96
97
 
98
+ /**
99
+ * Computes the difference between arrays.
100
+ *
101
+ * This function takes arrays and returns a new array containing the elements
102
+ * that are not present in any other arrays.
103
+ *
104
+ * @template T
105
+ * @param arrays - The arrays from which to derive the difference.
106
+ * @returns {T[]} A new array containing the elements that are not present in other arrays.
107
+ *
108
+ * @example
109
+ * const array1 = [1, 2, 3, 4, 5];
110
+ * const array2 = [2, 4];
111
+ * const array3 = [1, 5];
112
+ * const result = difference(array1, array2, array3);
113
+ * // result will be [3] since 1, 2, 4 and 5 are in other arrays and are excluded from the result.
114
+ */
115
+ declare function difference<T>(...arrays: readonly T[][]): T[];
116
+
117
+ /**
118
+ * Returns the intersection of arrays.
119
+ *
120
+ * This function takes arrays and returns a new array containing the elements that are
121
+ * present in all arrays.
122
+ *
123
+ * @template T - The type of elements in the array.
124
+ * @returns {T[]} A new array containing the elements that are present in both arrays.
125
+ *
126
+ * @example
127
+ * const array1 = [1, 2, 3, 4, 5];
128
+ * const array2 = [3, 4, 5, 6, 7];
129
+ * const result = intersection(array1, array2);
130
+ * // result will be [3, 4, 5] since these elements are in both arrays.
131
+ */
132
+ declare function intersection<T>(...arrays: readonly T[][]): T[];
133
+
97
134
  type MaybePropertyKey<T> = T extends object
98
135
  ? keyof T | PropertyKey
99
136
  : PropertyKey;
@@ -158,6 +195,22 @@ declare function keyBy<T, K extends PropertyKey>(array: readonly T[], keyBy: (it
158
195
  */
159
196
  declare function orderBy<T>(array: readonly T[], fields: (string | ((item: T) => any))[], orders: ('asc' | 'desc')[]): readonly T[];
160
197
 
198
+ /**
199
+ * Randomizes the order of elements in an array using the Fisher-Yates algorithm.
200
+ *
201
+ * This function takes an array and returns a new array with its elements shuffled in a random order.
202
+ *
203
+ * @template T - The type of elements in the array.
204
+ * @param {T[]} arr - The array to shuffle.
205
+ * @returns {T[]} A new array with its elements shuffled in random order.
206
+ *
207
+ * @example
208
+ * const array = [1, 2, 3, 4, 5];
209
+ * const shuffledArray = shuffle(array);
210
+ * // shuffledArray will be a new array with elements of array in random order, e.g., [3, 1, 4, 5, 2]
211
+ */
212
+ declare function shuffle<T>(arr: readonly T[]): T[];
213
+
161
214
  /**
162
215
  * Sums the values in an array of numbers, ignoring non-numeric values.
163
216
  *
@@ -196,7 +249,7 @@ declare const sum: (values: readonly number[]) => number;
196
249
  *
197
250
  * @group Array
198
251
  */
199
- declare function union<T>(arr1: readonly T[], arr2: readonly T[]): T[];
252
+ declare function union<T>(...arrays: readonly T[][]): T[];
200
253
 
201
254
  /**
202
255
  * Returns a new array with duplicates removed.
@@ -293,6 +346,345 @@ declare namespace assert {
293
346
  export { assert_array as array, assert_arrayNumbers as arrayNumbers, assert_arrayStrings as arrayStrings, assert_boolean as boolean, assert_equal as equal, assert_notEmptyString as notEmptyString, assert_number as number, assert_object as object, assert_ok as ok, assert_string as string };
294
347
  }
295
348
 
349
+ type Base64ToBytesOptions = {
350
+ /**
351
+ * Encoding type
352
+ */
353
+ encoding?: 'base64' | 'base64url';
354
+ /**
355
+ * Whether to enforce strict Base64 decoding.
356
+ */
357
+ strict?: boolean;
358
+ };
359
+ /**
360
+ * Decodes a Base64 or Base64URL encoded string into a `Uint8Array`.
361
+ *
362
+ * This function supports decoding data from both standard Base64 and Base64URL formats.
363
+ *
364
+ * @param {string} data - The encoded string to decode. Must be a valid Base64 or Base64URL encoded string.
365
+ * @param {Base64ToBytesOptions} [options] - Optional configuration options for decoding.
366
+ * @returns {Uint8Array} - The decoded byte array.
367
+ *
368
+ * @example
369
+ * // Example 1: Decoding a Base64 string
370
+ * const base64String = 'SGVsbG8gd29ybGQ='; // "Hello world"
371
+ * const decodedBytes = base64ToBytes(base64String);
372
+ * console.log(decodedBytes); // Output: Uint8Array [ 72, 101, 108, 108, 111, 32, 119, 111, 114, 108, 100 ]
373
+ *
374
+ * @example
375
+ * // Example 2: Decoding a Base64URL encoded string
376
+ * const base64urlString = 'SGVsbG8gd29ybGQ'; // "Hello world"
377
+ * const decodedBytes2 = base64ToBytes(base64urlString, { encoding: 'base64url' });
378
+ * console.log(decodedBytes2); // Output: Uint8Array [ 72, 101, 108, 108, 111, 32, 119, 111, 114, 108, 100 ]
379
+ *
380
+ * @example
381
+ * // Example 3: Strict decoding with Base64
382
+ * const base64StringStrict = 'SGVsbG8gd29ybGQ=';
383
+ * const decodedStrict = base64ToBytes(base64StringStrict, { strict: true });
384
+ * console.log(decodedStrict); // Output: Uint8Array [ 72, 101, 108, 108, 111, 32, 119, 111, 114, 108, 100 ]
385
+ *
386
+ * @group Binary
387
+ */
388
+ declare function base64ToBytes(data: string, { encoding, strict }?: Base64ToBytesOptions): Uint8Array;
389
+
390
+ /**
391
+ * Converts a `bigint` value into a byte array (`Uint8Array`) in big-endian order.
392
+ *
393
+ * This function encodes the absolute value of the provided `bigint` into a minimal byte array,
394
+ * ensuring that the bytes represent the value in big-endian format.
395
+ *
396
+ * @param {bigint} value - The input `bigint` value to convert into bytes.
397
+ * @returns {Uint8Array} - The byte array (`Uint8Array`) representing the provided `bigint`.
398
+ *
399
+ * @example
400
+ * // Example 1: Convert a positive bigint to bytes
401
+ * const value = 1234567890123456789n;
402
+ * const bytes = bigIntBytes(value);
403
+ * console.log(bytes); // Output: Uint8Array representing the bytes in big-endian
404
+ *
405
+ * @example
406
+ * // Example 2: Convert a negative bigint to bytes
407
+ * const valueNegative = -1234567890123456789n;
408
+ * const bytesNegative = bigIntBytes(valueNegative);
409
+ * console.log(bytesNegative); // Output: Uint8Array representing the absolute value in big-endian
410
+ *
411
+ * @example
412
+ * // Example 3: Handle very small bigints
413
+ * const smallValue = 42n;
414
+ * const bytesSmall = bigIntBytes(smallValue);
415
+ * console.log(bytesSmall); // Output: Uint8Array [ 42 ]
416
+ *
417
+ * @example
418
+ * // Example 4: Convert zero value
419
+ * const zeroValue = 0n;
420
+ * const bytesZero = bigIntBytes(zeroValue);
421
+ * console.log(bytesZero); // Output: Uint8Array [ 0 ]
422
+ *
423
+ * @group Binary
424
+ */
425
+ declare function bigIntBytes(value: bigint): Uint8Array;
426
+
427
+ /**
428
+ * Converts a byte array (`Uint8Array`) into a `bigint`. The byte array is interpreted in big-endian order.
429
+ *
430
+ * This function takes a byte array and decodes it into its corresponding `bigint` value by treating
431
+ * the byte array as a big-endian encoded number.
432
+ *
433
+ * @param {Uint8Array} bytes - The byte array to decode into a `bigint`. Must have at least one byte.
434
+ * @returns {bigint} - The decoded `bigint` value.
435
+ *
436
+ * @throws {Error} Will throw an error if the input byte array is empty.
437
+ *
438
+ * @example
439
+ * // Example 1: Decode a simple byte array
440
+ * const byteArray = new Uint8Array([0, 0, 0, 42]); // Represents the number 42 in big-endian
441
+ * const decodedValue = bigIntFromBytes(byteArray);
442
+ * console.log(decodedValue); // Output: 42n
443
+ *
444
+ * @example
445
+ * // Example 2: Decode a multi-byte number
446
+ * const byteArrayMulti = new Uint8Array([0x12, 0x34, 0x56, 0x78]); // Represents the number 305419896
447
+ * const decodedMulti = bigIntFromBytes(byteArrayMulti);
448
+ * console.log(decodedMulti); // Output: 305419896n
449
+ *
450
+ * @example
451
+ * // Example 3: Decode a single byte number
452
+ * const byteArraySingle = new Uint8Array([255]); // Represents the number 255
453
+ * const decodedSingle = bigIntFromBytes(byteArraySingle);
454
+ * console.log(decodedSingle); // Output: 255n
455
+ *
456
+ * @example
457
+ * // Example 4: Attempt decoding an invalid empty array
458
+ * try {
459
+ * const emptyArray = new Uint8Array([]);
460
+ * const decodedEmpty = bigIntFromBytes(emptyArray);
461
+ * } catch (error) {
462
+ * console.error(error); // Output: Error: Empty Uint8Array
463
+ * }
464
+ *
465
+ * @group Binary
466
+ */
467
+ declare function bigIntFromBytes(bytes: Uint8Array): bigint;
468
+
469
+ type BytesToBase64Options = {
470
+ /**
471
+ * Specifies the encoding type.
472
+ */
473
+ encoding?: 'base64' | 'base64url';
474
+ /**
475
+ * Whether or not to include padding (`=`) in the encoded result. Defaults to `true` for Base64, `false` for Base64URL.
476
+ */
477
+ padding?: boolean;
478
+ };
479
+ /**
480
+ * Encodes a byte array (`Uint8Array`) into a Base64 or Base64URL encoded string.
481
+ *
482
+ * The function can encode bytes in either the standard Base64 format or Base64URL format,
483
+ * depending on the specified options. It also allows control over whether padding is included.
484
+ *
485
+ * @param {Uint8Array} data - The byte array to encode into Base64 or Base64URL.
486
+ * @param {BytesToBase64Options} [options] - Optional configuration options.
487
+ * @returns {string} - The encoded Base64 or Base64URL string.
488
+ *
489
+ * @example
490
+ * // Example 1: Encoding with Base64 with default padding
491
+ * const byteArray = new Uint8Array([72, 101, 108, 108, 111, 32, 119, 111, 114, 108, 100]); // "Hello world"
492
+ * const encodedBase64 = bytesToBase64(byteArray);
493
+ * console.log(encodedBase64); // Output: 'SGVsbG8gd29ybGQ='
494
+ *
495
+ * @example
496
+ * // Example 2: Encoding with Base64URL without padding
497
+ * const byteArray2 = new Uint8Array([72, 101, 108, 108, 111, 32, 119, 111, 114, 108, 100]); // "Hello world"
498
+ * const encodedBase64URL = bytesToBase64(byteArray2, { encoding: 'base64url', padding: false });
499
+ * console.log(encodedBase64URL); // Output: 'SGVsbG8gd29ybGQ'
500
+ *
501
+ * @example
502
+ * // Example 3: Encoding with Base64 with no padding
503
+ * const byteArray3 = new Uint8Array([1, 2, 3, 4]);
504
+ * const encodedNoPadding = bytesToBase64(byteArray3, { encoding: 'base64', padding: false });
505
+ * console.log(encodedNoPadding); // Output: 'AQIDBA'
506
+ *
507
+ * @example
508
+ * // Example 4: Handling invalid encoding options
509
+ * try {
510
+ * const invalidEncoding = bytesToBase64(byteArray3, { encoding: 'invalid' });
511
+ * } catch (error) {
512
+ * console.error(error); // Output: Error: Invalid encoding options: invalid
513
+ * }
514
+ *
515
+ * @group Binary
516
+ */
517
+ declare function bytesToBase64(data: Uint8Array, { encoding, padding }?: BytesToBase64Options): string;
518
+
519
+ /**
520
+ * Compares two `Uint8Array` instances to check if their contents are identical.
521
+ *
522
+ * This function compares each byte of the two provided byte arrays. It returns `true`
523
+ * only if both byte arrays are of the same length **and** contain identical byte values
524
+ * at every index. Otherwise, it returns `false`.
525
+ *
526
+ * @param {Uint8Array} a - The first byte array to compare.
527
+ * @param {Uint8Array} b - The second byte array to compare.
528
+ * @returns {boolean} `true` if the byte arrays are identical; otherwise, `false`.
529
+ *
530
+ * @example
531
+ * // Example with identical byte arrays
532
+ * const a = new Uint8Array([1, 2, 3]);
533
+ * const b = new Uint8Array([1, 2, 3]);
534
+ * console.log(compareBytes(a, b)); // Output: true
535
+ *
536
+ * @example
537
+ * // Example with different contents
538
+ * const a = new Uint8Array([1, 2, 3]);
539
+ * const b = new Uint8Array([1, 2, 4]);
540
+ * console.log(compareBytes(a, b)); // Output: false
541
+ *
542
+ * @example
543
+ * // Example with different lengths
544
+ * const a = new Uint8Array([1, 2]);
545
+ * const b = new Uint8Array([1, 2, 3]);
546
+ * console.log(compareBytes(a, b)); // Output: false
547
+ *
548
+ * @example
549
+ * // Example with both arrays empty
550
+ * const a = new Uint8Array([]);
551
+ * const b = new Uint8Array([]);
552
+ * console.log(compareBytes(a, b)); // Output: true
553
+ *
554
+ * @group Binary
555
+ */
556
+ declare function compareBytes(a: Uint8Array, b: Uint8Array): boolean;
557
+
558
+ /**
559
+ * Concatenates two `Uint8Array` instances into a single new `Uint8Array`.
560
+ *
561
+ * This function takes two byte arrays, `a` and `b`, and creates a new `Uint8Array`
562
+ * that combines their contents in order. The result will have a length equal to the
563
+ * sum of the lengths of `a` and `b`.
564
+ *
565
+ * @param {Uint8Array} a - The first byte array to concatenate.
566
+ * @param {Uint8Array} b - The second byte array to concatenate.
567
+ * @returns {Uint8Array} A new `Uint8Array` containing the concatenation of `a` and `b`.
568
+ *
569
+ * @example
570
+ * // Example with simple byte arrays
571
+ * const a = new Uint8Array([1, 2, 3]);
572
+ * const b = new Uint8Array([4, 5, 6]);
573
+ * const result = concatenateBytes(a, b);
574
+ * console.log(result); // Output: Uint8Array(6) [1, 2, 3, 4, 5, 6]
575
+ *
576
+ * @example
577
+ * // Example with empty arrays
578
+ * const a = new Uint8Array([]);
579
+ * const b = new Uint8Array([1, 2, 3]);
580
+ * const result = concatenateBytes(a, b);
581
+ * console.log(result); // Output: Uint8Array(3) [1, 2, 3]
582
+ *
583
+ * @example
584
+ * // Example with reversed order
585
+ * const a = new Uint8Array([10, 20]);
586
+ * const b = new Uint8Array([30, 40]);
587
+ * const result = concatenateBytes(a, b);
588
+ * console.log(result); // Output: Uint8Array(4) [10, 20, 30, 40]
589
+ *
590
+ * @group Binary
591
+ */
592
+ declare function concatenateBytes(a: Uint8Array, b: Uint8Array): Uint8Array;
593
+
594
+ /**
595
+ * Converts a `Uint16Array` into a `Uint8Array`.
596
+ *
597
+ * @param {Uint16Array} value - The input `Uint16Array` to convert.
598
+ * @returns {Uint8Array} - The resulting `Uint8Array`, with length twice that of the input `Uint16Array`.
599
+ *
600
+ * @example
601
+ * // Example 1: Converting a valid Uint16Array into a Uint8Array
602
+ * const uint16Array = new Uint16Array([0x1234, 0x5678]);
603
+ * const uint8Array = uint16ToUint8(uint16Array);
604
+ * console.log(uint8Array); // Output: Uint8Array [ 0x34, 0x12, 0x78, 0x56 ]
605
+ *
606
+ * @example
607
+ * // Example 2: Another conversion example
608
+ * const uint16Array2 = new Uint16Array([0xabcd, 0x1234, 0x5678]);
609
+ * const uint8Array2 = uint16ToUint8(uint16Array2);
610
+ * console.log(uint8Array2); // Output: Uint8Array [ 0xcd, 0xab, 0x34, 0x12, 0x78, 0x56 ]
611
+ *
612
+ * @group Binary
613
+ */
614
+ declare function uint16ToUint8(value: Uint16Array): Uint8Array;
615
+
616
+ /**
617
+ * Converts a `Uint32Array` into a `Uint8Array`.
618
+ *
619
+ * @param {Uint32Array} value - The input `Uint32Array` to convert.
620
+ * @returns {Uint8Array} - The resulting `Uint8Array`, with length four times that of the input `Uint32Array`.
621
+ *
622
+ * @example
623
+ * // Example 1: Converting a valid Uint32Array into a Uint8Array
624
+ * const uint32Array = new Uint32Array([0x12345678, 0x9abcdef0]);
625
+ * const uint8Array = uint32ToUint8(uint32Array);
626
+ * console.log(uint8Array); // Output: Uint8Array [ 0x78, 0x56, 0x34, 0x12, 0xf0, 0xde, 0xbc, 0x9a ]
627
+ *
628
+ * @example
629
+ * // Example 2: Another conversion example with different numbers
630
+ * const uint32Array2 = new Uint32Array([0xffffffff, 0x00000000]);
631
+ * const uint8Array2 = uint32ToUint8(uint32Array2);
632
+ * console.log(uint8Array2); // Output: Uint8Array [ 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00 ]
633
+ *
634
+ * @example
635
+ * // Example 3: Handling edge values
636
+ * const uint32Array3 = new Uint32Array([0x0, 0x00000001]);
637
+ * const uint8Array3 = uint32ToUint8(uint32Array3);
638
+ * console.log(uint8Array3); // Output: Uint8Array [ 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00 ]
639
+ *
640
+ * @group Binary
641
+ */
642
+ declare function uint32ToUint8(value: Uint32Array): Uint8Array;
643
+
644
+ /**
645
+ * Converts a Uint8Array to a Uint16Array.
646
+ *
647
+ * @param {Uint8Array} value - The input byte array to convert. Must have an even length.
648
+ * @returns {Uint16Array} - The converted Uint16Array.
649
+ *
650
+ * @example
651
+ * // Example 1: Converting a valid Uint8Array into a Uint16Array
652
+ * const uint8Array = new Uint8Array([0x12, 0x34, 0x56, 0x78]);
653
+ * const uint16Array = uint8ToUint16(uint8Array);
654
+ * console.log(uint16Array); // Output: Uint16Array [ 0x1234, 0x5678 ]
655
+ *
656
+ * @example
657
+ * // Example 2: Another conversion example
658
+ * const uint8Array2 = new Uint8Array([0xff, 0xee, 0xdd, 0xcc]);
659
+ * const uint16Array2 = uint8ToUint16(uint8Array2);
660
+ * console.log(uint16Array2); // Output: Uint16Array [ 0xffee, 0xddcc ]
661
+ *
662
+ * @group Binary
663
+ */
664
+ declare function uint8ToUint16(value: Uint8Array): Uint16Array;
665
+
666
+ /**
667
+ * Converts a `Uint8Array` into a `Uint32Array`.
668
+ *
669
+ * @param {Uint8Array} value - The input byte array to convert. Length must be a multiple of 4.
670
+ * @returns {Uint32Array} - The converted array of 32-bit unsigned integers.
671
+ *
672
+ * @example
673
+ * // Example 1: Converting a valid Uint8Array into a Uint32Array
674
+ * const uint8Array = new Uint8Array([0x12, 0x34, 0x56, 0x78, 0x9a, 0xbc, 0xde, 0xf0]);
675
+ * const uint32Array = uint8ToUint32(uint8Array);
676
+ * console.log(uint32Array); // Output: Uint32Array [ 0x78563412, 0xf0debc9a ]
677
+ *
678
+ * @example
679
+ * // Example 2: Another conversion example
680
+ * const uint8Array2 = new Uint8Array([0xff, 0xee, 0xdd, 0xcc, 0xab, 0xcd, 0xef, 0x01]);
681
+ * const uint32Array2 = uint8ToUint32(uint8Array2);
682
+ * console.log(uint32Array2); // Output: Uint32Array [ 0xccddeeff, 0x01abcded ]
683
+ *
684
+ * @group Binary
685
+ */
686
+ declare function uint8ToUint32(value: Uint8Array): Uint32Array;
687
+
296
688
  type Arrayable<T> = T[] | T;
297
689
 
298
690
  type Awaitable<T> = Promise<T> | T;
@@ -342,11 +734,53 @@ type PromisifyFn<T extends AnyFunction> = (
342
734
  ...args: ArgumentsType<T>
343
735
  ) => Promise<ReturnType<T>>;
344
736
 
737
+ /**
738
+ * A time value, which can be a string (e.g., "HH:MM"),
739
+ * an object with `h` (hours) and `m` (minutes) properties, or a similar format
740
+ * that `createTimeObject` can parse.
741
+ */
742
+ type TimeValue = TimeString | TimeObject;
743
+
744
+ /**
745
+ * Represent time string in 24h format
746
+ */
747
+ type TimeString = string;
748
+
749
+ /**
750
+ * Represent time object in 24h format ("HH:MM")
751
+ */
345
752
  type TimeObject = {
753
+ /**
754
+ * Hour (0 - 23).
755
+ */
346
756
  h: number;
757
+
758
+ /**
759
+ * Minutes (0 - 59).
760
+ */
347
761
  m: number;
348
762
  };
349
763
 
764
+ /**
765
+ * Represent date object
766
+ */
767
+ type DateObject = {
768
+ /**
769
+ * The year of the date (e.g., 2024).
770
+ */
771
+ year: number;
772
+
773
+ /**
774
+ * The month of the date (1 = January, 12 = December).
775
+ */
776
+ month: number;
777
+
778
+ /**
779
+ * The day of the month (1-31).
780
+ */
781
+ date: number;
782
+ };
783
+
350
784
  interface ThemeConfig {
351
785
  colors: {
352
786
  [x: string]: Record<string, string>;
@@ -891,9 +1325,9 @@ declare function withPointerCache<T>(pointer: object, dependencies: string[], fn
891
1325
  */
892
1326
  declare function captureStackTrace(till: AnyFunction): string;
893
1327
 
894
- type ToCatchResult<T> = T extends Promise<any> ? Promise<CatchSuccessResult<Awaited<T>> | CatchErrorResult> : CatchSuccessResult<T> | CatchErrorResult;
895
- type CatchErrorResult = [Error, undefined];
896
- type CatchSuccessResult<T> = [undefined, T];
1328
+ type CatchErrorResult<T> = T extends Promise<unknown> ? Promise<OkResult<Awaited<T>> | ErrorResult> : OkResult<T> | ErrorResult;
1329
+ type ErrorResult = [Error, undefined];
1330
+ type OkResult<T> = [undefined, T];
897
1331
  /**
898
1332
  * You're tired to write `try... catch`, and so are we.
899
1333
  *
@@ -906,7 +1340,7 @@ type CatchSuccessResult<T> = [undefined, T];
906
1340
  *
907
1341
  * @group Errors
908
1342
  */
909
- declare function catchError<T>(fn: () => T): ToCatchResult<T>;
1343
+ declare function catchError<T>(fn: () => T): CatchErrorResult<T>;
910
1344
 
911
1345
  declare namespace Color {
912
1346
  /**
@@ -1143,110 +1577,899 @@ declare const ColorParser: {
1143
1577
  */
1144
1578
  declare function crc32(str: string, seed?: number): number;
1145
1579
 
1146
- type Dict<T> = {
1147
- [key: string]: T | undefined;
1148
- };
1149
- type ListTypeName = 'bool' | 'int' | 'decimal' | 'string';
1150
- type ListTypeNameToType<T extends ListTypeName> = T extends 'bool' ? boolean : T extends 'int' ? number : T extends 'decimal' ? number : T extends 'string' ? string : never;
1580
+ type DateObjectInput = Date | string | number | DateObject;
1581
+ declare function createDateObject(value: DateObjectInput): DateObject;
1582
+ declare function createDateObject(value: DateObjectInput, returnsNullWhenInvalid: true): DateObject | null;
1583
+
1584
+ type TimeObjectInput = Date | number | string | TimeObject;
1585
+ declare function createTimeObject(value: TimeObjectInput): TimeObject;
1586
+ declare function createTimeObject(value: TimeObjectInput, returnsNullWhenInvalid: true): TimeObject | null;
1587
+
1588
+ type TimeSpanUnit = 'ms' | 's' | 'm' | 'h' | 'd' | 'w';
1151
1589
  /**
1152
- * Environment variable parser
1153
- *
1154
- * @group Environment
1590
+ * A class representing a span of time with a specific value and unit of measurement.
1591
+ * Provides methods for conversion between time units and arithmetic operations (add, subtract).
1155
1592
  */
1156
- interface EnvParser {
1593
+ declare class TimeSpan {
1594
+ constructor(value: number, unit: TimeSpanUnit);
1157
1595
  /**
1158
- * NODE_ENV is `development`
1596
+ * The numeric value of the time span
1159
1597
  */
1160
- isDevelopment: boolean;
1598
+ value: number;
1161
1599
  /**
1162
- * NODE_ENV is `production`
1600
+ * The unit of the time span.
1163
1601
  */
1164
- isProduction: boolean;
1602
+ unit: TimeSpanUnit;
1165
1603
  /**
1166
- * NODE_ENV is `stage`
1604
+ * Converts the time span to milliseconds.
1605
+ *
1606
+ * @returns {number} The equivalent time span in milliseconds.
1607
+ * @example
1608
+ * const ts = new TimeSpan(2, 'h');
1609
+ * ts.milliseconds(); // Returns 7200000
1167
1610
  */
1168
- isStage: boolean;
1611
+ milliseconds(): number;
1169
1612
  /**
1170
- * Returns `true` when environment key has set to `"true"`
1613
+ * Converts the time span to seconds.
1171
1614
  *
1172
- * Returns `defaultValue` when key is not defined
1615
+ * @returns {number} The equivalent time span in seconds.
1616
+ * @example
1617
+ * const ts = new TimeSpan(2, 'm');
1618
+ * ts.seconds(); // Returns 120
1173
1619
  */
1174
- bool(key: string, defaultValue?: boolean): boolean;
1620
+ seconds(): number;
1175
1621
  /**
1176
- * Returns `number` when environment key has correct number value.
1622
+ * Converts the time span to minutes.
1177
1623
  *
1178
- * Returns `defaultValue` when environment key is not defined or has invalid number value
1624
+ * @returns {number} The equivalent time span in minutes.
1625
+ * @example
1626
+ * const ts = new TimeSpan(120, 's');
1627
+ * ts.minutes(); // Returns 2
1179
1628
  */
1180
- int(key: string, defaultValue?: number): number;
1629
+ minutes(): number;
1181
1630
  /**
1182
- * Returns `number` when environment key has correct number value.
1631
+ * Converts the time span to hours.
1183
1632
  *
1184
- * Returns `defaultValue` when environment key is not defined or has invalid number value
1633
+ * @returns {number} The equivalent time span in hours.
1634
+ * @example
1635
+ * const ts = new TimeSpan(120, 'm');
1636
+ * ts.hours(); // Returns 2
1185
1637
  */
1186
- decimal(key: string, dights?: number, defaultValue?: number): number;
1638
+ hours(): number;
1187
1639
  /**
1188
- * Returns `string` when environment key has defined.
1640
+ * Converts the time span to days.
1189
1641
  *
1190
- * Returns `defaultValue` when environment key is not defined
1642
+ * @returns {number} The equivalent time span in days.
1643
+ * @example
1644
+ * const ts = new TimeSpan(48, 'h');
1645
+ * ts.days(); // Returns 2
1191
1646
  */
1192
- string(key: string, defaultValue?: string): string;
1647
+ days(): number;
1193
1648
  /**
1194
- * Returns `array` of parsed environment value.
1649
+ * Converts the time span to weeks.
1195
1650
  *
1196
- * Returns `defaultValue` when key is not defined
1651
+ * @returns {number} The equivalent time span in weeks.
1652
+ * @example
1653
+ * const ts = new TimeSpan(14, 'd');
1654
+ * ts.weeks(); // Returns 2
1197
1655
  */
1198
- list<T extends ListTypeName>(key: string, itemType: T, defaultValue?: ListTypeNameToType<T>[]): ListTypeNameToType<T>[];
1656
+ weeks(): number;
1199
1657
  /**
1200
- * Returns parsed json value.
1658
+ * Adds a specified value and unit to the current time span.
1201
1659
  *
1202
- * Returns `defaultValue` when key is not defined or invalid json value
1660
+ * Returns new instance.
1661
+ *
1662
+ * @param {number} value - The value to add.
1663
+ * @param {TimeSpanUnit} [unit='ms'] - The unit of the value to add (default is milliseconds).
1664
+ * @returns {TimeSpan} A new TimeSpan instance with the added value.
1665
+ * @example
1666
+ * const ts = new TimeSpan(1, 'h');
1667
+ * ts.add(30, 'm'); // Represents 1.5 hours
1203
1668
  */
1204
- json<T = any>(key: string, defaultValue?: T | null): T | null;
1669
+ add(value: number, unit?: TimeSpanUnit): TimeSpan;
1670
+ /**
1671
+ * Subtracts a specified value and unit from the current time span.
1672
+ *
1673
+ * Returns new instance.
1674
+ *
1675
+ * @param {number} value - The value to subtract.
1676
+ * @param {TimeSpanUnit} [unit='ms'] - The unit of the value to subtract (default is milliseconds).
1677
+ * @returns {TimeSpan} A new TimeSpan instance with the subtracted value.
1678
+ * @example
1679
+ * const ts = new TimeSpan(1, 'h');
1680
+ * ts.subtract(30, 'm'); // Represents 30 minutes less than 1 hour
1681
+ */
1682
+ subtract(value: number, unit?: TimeSpanUnit): TimeSpan;
1205
1683
  }
1684
+
1206
1685
  /**
1207
- * Ready-to-use environment parser.
1686
+ * Creates a new instance of `TimeSpan`.
1208
1687
  *
1209
- * Target: `process.env`
1688
+ * This utility function allows you to create a `TimeSpan` object by providing a numeric value and a unit of time.
1689
+ * The default unit is `'ms'` (milliseconds).
1210
1690
  *
1211
- * Fallback: `import.meta.env`
1691
+ * @param {number} value - The numeric value representing the timespan.
1692
+ * @param {TimeSpanUnit} [unit='ms'] - The unit of time for the timespan value. Options are `'ms'`, `'s'`, `'m'`, `'h'`, `'d'`, `'w'`.
1693
+ * @returns {TimeSpan} An instance of the `TimeSpan` class.
1694
+ * @example
1695
+ * // Create a TimeSpan with 500 milliseconds
1696
+ * const ts = createTimeSpan(500);
1697
+ * console.log(ts.milliseconds()); // 500
1212
1698
  *
1213
1699
  * @example
1700
+ * // Create a TimeSpan with 2 hours
1701
+ * const ts = createTimeSpan(2, 'h');
1702
+ * console.log(ts.seconds()); // 120
1214
1703
  *
1215
- * // env.string
1216
- * const API_KEY = env.string('API_KEY', 'test_key');
1704
+ * @example
1705
+ * // Create a TimeSpan with 7 days
1706
+ * const ts = createTimeSpan(7, 'd');
1707
+ * console.log(ts.weeks()); // 1
1217
1708
  *
1218
- * // env.bool
1219
- * const TEST_FEATURE = env.bool('TEST_FEATURE', false);
1709
+ * @group Date
1710
+ */
1711
+ declare function createTimeSpan(value: number, unit?: TimeSpanUnit): TimeSpan;
1712
+
1713
+ /**
1714
+ * The base time as a timestamp, `Date` object,
1715
+ * or a similar format that the `timestampMs` function can parse.
1716
+ */
1717
+ type TimestampMsInput = Date | string | number;
1718
+ /**
1719
+ * Returns or converts the given input into milliseconds since the Unix epoch.
1220
1720
  *
1221
- * // env.int
1222
- * const RETRY_ATTEMPTS = env.int('RETRY_ATTEMPTS', 5);
1721
+ * @param {TimestampMsInput} [fromValue=Date.now()] - The input value to be converted to milliseconds.
1722
+ * Can be a `Date` object, a timestamp (number), or a string representing a date.
1723
+ * Defaults to the current time.
1724
+ * @returns {number} The number of milliseconds since the Unix epoch. Returns `0` if the input is invalid.
1223
1725
  *
1224
- * // env.decimal
1225
- * const DELAY_SECONDS = env.decimal('DELAY_SECONDS', 2, 5); // round to 2 dights
1726
+ * @example
1727
+ * // Get milliseconds from a Date object
1728
+ * timestampMs(new Date('2023-01-01T00:00:00Z')); // 1672531200000
1226
1729
  *
1227
- * // env.list
1228
- * const TARGET_ROLES = env.list('TARGET_ROLES', 'string', ['ADMIN']);
1730
+ * @example
1731
+ * // Get milliseconds from a timestamp
1732
+ * timestampMs(1672531200000); // 1672531200000
1229
1733
  *
1230
- * // env.json
1231
- * const GOOGLE_CREDS = env.json<{ projectId: string; token: string; }>('GOOGLE_CREDS');
1734
+ * @example
1735
+ * // Get milliseconds from a date string
1736
+ * timestampMs('2023-01-01T00:00:00Z'); // 1672531200000
1232
1737
  *
1233
- * @group Environment
1234
- */
1235
- declare const env: Readonly<EnvParser>;
1236
- /**
1237
1738
  * @example
1238
- * const env = createEnvParser(process.env);
1239
- * // const env = createEnvParser(import.meta.env);
1739
+ * // Handle invalid input
1740
+ * timestampMs('invalid-date'); // 0
1240
1741
  *
1241
- * const API_KEY = env.string('API_KEY', 'test_key');
1742
+ * @example
1743
+ * // Use the default value (current time)
1744
+ * timestampMs(); // Current timestamp in milliseconds
1242
1745
  *
1243
- * @group Environment
1746
+ * @group Date
1244
1747
  */
1245
- declare function createEnvParser(targetObject: Record<string, string> | Dict<string>): Readonly<EnvParser>;
1748
+ declare function timestampMs(fromValue?: TimestampMsInput): number;
1246
1749
 
1247
1750
  /**
1248
- * Simple application error class with the code
1249
- * @group Errors
1751
+ * Returns a `Date` object representing a time that is the given number of days
1752
+ * before or after a base time.
1753
+ *
1754
+ * @param {number} days - The number of days to add to or subtract from the base time.
1755
+ * Positive values move forward in time, and negative values move backward.
1756
+ * @param {TimestampMsInput} [fromValue=Date.now()] - The base time as a timestamp.
1757
+ * @returns {Date} A `Date` object representing the computed time.
1758
+ *
1759
+ * @example
1760
+ * // Get the date 7 days from now
1761
+ * dateInDays(7); // Returns a Date object 7 days in the future
1762
+ *
1763
+ * @example
1764
+ * // Get the date 5 days before a specific time
1765
+ * dateInDays(-5, new Date('2023-01-01T00:00:00Z')); // Returns 2022-12-27T00:00:00Z
1766
+ *
1767
+ * @example
1768
+ * // Use a timestamp as the base time
1769
+ * dateInDays(2, 1672531200000); // Returns a Date object 2 days after the base timestamp
1770
+ *
1771
+ * @group Date
1772
+ */
1773
+ declare function dateInDays(days: number, fromValue?: TimestampMsInput): Date;
1774
+
1775
+ /**
1776
+ * Returns a `Date` object representing a time that is the given number of seconds
1777
+ * before or after a base time.
1778
+ *
1779
+ * @param {number} seconds - The number of seconds to add to or subtract from the base time.
1780
+ * Positive values move forward in time, and negative values move backward.
1781
+ * @param {TimestampMsInput} [fromValue=Date.now()] - The base time.
1782
+ * @returns {Date} A `Date` object representing the computed time.
1783
+ *
1784
+ * @example
1785
+ * // Get the date 60 seconds from now
1786
+ * dateInSeconds(60); // Returns a Date object 1 minute in the future
1787
+ *
1788
+ * @example
1789
+ * // Get the date 30 seconds before a specific time
1790
+ * dateInSeconds(-30, new Date('2023-01-01T00:00:00Z')); // Returns 2022-12-31T23:59:30Z
1791
+ *
1792
+ * @example
1793
+ * // Use a timestamp as the base time
1794
+ * dateInSeconds(10, 1672531200000); // Returns a Date object 10 seconds after the base timestamp
1795
+ *
1796
+ * @group Date
1797
+ */
1798
+ declare function dateInSeconds(seconds: number, fromValue?: TimestampMsInput): Date;
1799
+
1800
+ /**
1801
+ * Gets a random time within the specified range.
1802
+ *
1803
+ * Generates a random hour (`h`) and minute (`m`) between the given `startTime` and `endTime`.
1804
+ * If no range is provided, it defaults to the full day from `{ h: 0, m: 0 }` to `{ h: 23, m: 59 }`.
1805
+ *
1806
+ * @param {TimeObject} [startTime={ h: 0, m: 0 }] - The starting range for the random time.
1807
+ * @param {TimeObject} [endTime={ h: 23, m: 59 }] - The ending range for the random time.
1808
+ * @returns {TimeObject} - A random time object with `h` and `m` values within the given range.
1809
+ *
1810
+ * @example
1811
+ * // Generate a random time within the full day
1812
+ * const randomTime = getRandomTime();
1813
+ * console.log(randomTime); // e.g., { h: 12, m: 34 }
1814
+ *
1815
+ * @example
1816
+ * // Generate a random time between 9:00 and 17:00
1817
+ * const randomTime = getRandomTime({ h: 9, m: 0 }, { h: 17, m: 0 });
1818
+ * console.log(randomTime); // e.g., { h: 12, m: 15 }
1819
+ *
1820
+ * @example
1821
+ * // Generate a random time between 8:30 and 10:30
1822
+ * const randomTime = getRandomTime({ h: 8, m: 30 }, { h: 10, m: 30 });
1823
+ * console.log(randomTime); // e.g., { h: 9, m: 45 }
1824
+ *
1825
+ * @group Date
1826
+ */
1827
+ declare function getRandomTime(startTime?: TimeObject, endTime?: TimeObject): TimeObject;
1828
+
1829
+ /**
1830
+ * Converts a decimal representation of hours and minutes (HH.MM) into total seconds.
1831
+ *
1832
+ * This function takes a decimal number in the format `HH.MM`, where:
1833
+ * - The integer part represents the number of hours.
1834
+ * - The fractional part represents the minutes (in decimal) and is converted accordingly.
1835
+ *
1836
+ * It returns the total time in seconds.
1837
+ *
1838
+ * @param {number} hm - The time represented in HH.MM format (e.g., 2.30 for 2 hours and 30 minutes).
1839
+ * @returns {number} - The total number of seconds equivalent to the provided HH.MM value.
1840
+ *
1841
+ * @example
1842
+ * hmToSeconds(1.00);
1843
+ * // Returns 3600 (1 hour = 3600 seconds)
1844
+ *
1845
+ * @example
1846
+ * hmToSeconds(2.30);
1847
+ * // Returns 9000 (2 hours and 30 minutes = 2 * 3600 + 30 * 60 = 9000 seconds)
1848
+ *
1849
+ * @example
1850
+ * hmToSeconds(0.15);
1851
+ * // Returns 900 (0 hours and 15 minutes = 15 minutes = 900 seconds)
1852
+ *
1853
+ * @example
1854
+ * hmToSeconds(3.45);
1855
+ * // Returns 13500 (3 hours and 45 minutes = 3 * 3600 + 45 * 60 = 13500 seconds)
1856
+ *
1857
+ * @group Date
1858
+ */
1859
+ declare function hmToSeconds(hm: number): number;
1860
+
1861
+ /**
1862
+ * Checks if a given value is a valid `DateObject`.
1863
+ *
1864
+ * A valid `DateObject` is an object that contains numeric `year`, `month`, and `date` properties.
1865
+ *
1866
+ * @param {unknown} value - The value to be checked.
1867
+ * @returns {value is DateObject} - Returns `true` if the value is a valid `DateObject`; otherwise, `false`.
1868
+ *
1869
+ * @example
1870
+ * // Valid DateObject
1871
+ * isDateObject({ year: 2024, month: 11, date: 8 }); // true
1872
+ *
1873
+ * @example
1874
+ * // Missing properties
1875
+ * isDateObject({ year: 2024, month: 11 }); // false
1876
+ *
1877
+ * @example
1878
+ * // Non-numeric values
1879
+ * isDateObject({ year: '2024', month: 11, date: 8 }); // false
1880
+ *
1881
+ * @example
1882
+ * // Non-object input
1883
+ * isDateObject('invalid'); // false
1884
+ *
1885
+ * @example
1886
+ * // Additional properties (still valid)
1887
+ * isDateObject({ year: 2024, month: 11, date: 8, extra: 'property' }); // true
1888
+ *
1889
+ * @group Date
1890
+ */
1891
+ declare function isDateObject(value: unknown): value is DateObject;
1892
+
1893
+ /**
1894
+ * Checks if a given value is a valid `TimeObject`.
1895
+ *
1896
+ * @param {unknown} value - The value to check if it's a valid `TimeObject`.
1897
+ * @returns {value is TimeObject} - Returns `true` if the value is a valid `TimeObject`, otherwise `false`.
1898
+ *
1899
+ * @example
1900
+ * // Valid TimeObject
1901
+ * isTimeObject({ h: 15, m: 30 }); // true
1902
+ *
1903
+ * @example
1904
+ * // Invalid TimeObject (missing `m`)
1905
+ * isTimeObject({ h: 15 }); // false
1906
+ *
1907
+ * @example
1908
+ * // Invalid TimeObject (non-number values)
1909
+ * isTimeObject({ h: '15', m: 30 }); // false
1910
+ * isTimeObject({ h: 15, m: '30' }); // false
1911
+ *
1912
+ * @example
1913
+ * // Invalid TimeObject (out-of-range hours)
1914
+ * isTimeObject({ h: -1, m: 30 }); // false
1915
+ * isTimeObject({ h: 24, m: 30 }); // false
1916
+ *
1917
+ * @example
1918
+ * // Invalid TimeObject (out-of-range minutes)
1919
+ * isTimeObject({ h: 15, m: -1 }); // false
1920
+ * isTimeObject({ h: 15, m: 60 }); // false
1921
+ *
1922
+ * @example
1923
+ * // Invalid TimeObject (non-object input)
1924
+ * isTimeObject('string'); // false
1925
+ * isTimeObject(123); // false
1926
+ * isTimeObject([]); // false
1927
+ *
1928
+ * @group Date
1929
+ */
1930
+ declare function isTimeObject(value: unknown): value is TimeObject;
1931
+
1932
+ /**
1933
+ * Checks if a given value is a valid `TimeString`.
1934
+ *
1935
+ * @param {unknown} value - The value to check if it's a valid `TimeString`.
1936
+ * @returns {value is TimeObject} - Returns `true` if the value is a valid `TimeString`, otherwise `false`.
1937
+ *
1938
+ * @example
1939
+ * // Valid TimeString
1940
+ * isTimeString('15:30'); // true
1941
+ *
1942
+ * @example
1943
+ * // Invalid TimeString
1944
+ * isTimeObject('15:30:00'); // false
1945
+ *
1946
+ * @example
1947
+ * // Invalid TimeString (out-of-range hours)
1948
+ * isTimeObject('26:00'); // false
1949
+ *
1950
+ * @group Date
1951
+ */
1952
+ declare function isTimeString(value: unknown): value is TimeString;
1953
+
1954
+ /**
1955
+ * Checks if a given value is a valid `TimeValue`.
1956
+ *
1957
+ * @param {unknown} value - The value to check if it's a valid `TimeValue`.
1958
+ * @returns {value is TimeObject} - Returns `true` if the value is a valid `TimeValue`, otherwise `false`.
1959
+ *
1960
+ * @example
1961
+ * // Valid TimeObject
1962
+ * isTimeValue({ h: 15, m: 30 }); // true
1963
+ *
1964
+ * @example
1965
+ * // Valid TimeString
1966
+ * isTimeValue('15:30'); // true
1967
+ *
1968
+ * @group Date
1969
+ */
1970
+ declare function isTimeValue(value: unknown): value is TimeValue;
1971
+
1972
+ /**
1973
+ * Checks if a given value is a valid weekday number.
1974
+ *
1975
+ * A valid weekday number is a number between 1 (Monday) and 7 (Sunday), inclusive.
1976
+ *
1977
+ * @param {unknown} value - The value to check if it's a valid weekday number.
1978
+ * @returns {value is number} - Returns `true` if the value is a number and represents a valid weekday, otherwise `false`.
1979
+ *
1980
+ * @example
1981
+ * // Valid weekday numbers
1982
+ * isValidWeekDay(1); // true
1983
+ * isValidWeekDay(7); // true
1984
+ *
1985
+ * @example
1986
+ * // Invalid weekday numbers
1987
+ * isValidWeekDay(0); // false
1988
+ * isValidWeekDay(8); // false
1989
+ * isValidWeekDay(-1); // false
1990
+ * isValidWeekDay('3'); // false
1991
+ * isValidWeekDay(null); // false
1992
+ * isValidWeekDay(undefined); // false
1993
+ *
1994
+ * @group Date
1995
+ */
1996
+ declare function isValidWeekDay(value: unknown): value is number;
1997
+
1998
+ /**
1999
+ * Converts seconds to a decimal representation of hours and minutes (HH.MM) rounded to two decimal places.
2000
+ *
2001
+ * This function takes a number of seconds, calculates the number of whole hours and minutes,
2002
+ * and converts them into a two-decimal representation where:
2003
+ * - The integer part represents the hours.
2004
+ * - The fractional part represents the minutes (rounded to 2 digits).
2005
+ *
2006
+ * @param {number} seconds - The total number of seconds to convert into hours and minutes.
2007
+ * @returns {number} - A decimal number in the format HH.MM representing the converted time.
2008
+ *
2009
+ * @example
2010
+ * secondsToHm(3661);
2011
+ * // Returns 1.01 (1 hour and 1 minute)
2012
+ *
2013
+ * @example
2014
+ * secondsToHm(7322);
2015
+ * // Returns 2.02 (2 hours and 2 minutes)
2016
+ *
2017
+ * @example
2018
+ * secondsToHm(59);
2019
+ * // Returns 0.59 (0 hours and 59 minutes)
2020
+ *
2021
+ * @example
2022
+ * secondsToHm(3600);
2023
+ * // Returns 1.00 (exactly 1 hour)
2024
+ *
2025
+ * @group Date
2026
+ */
2027
+ declare function secondsToHm(seconds: number): number;
2028
+
2029
+ declare function timeFromMinutes(value: number): TimeObject;
2030
+ declare function timeFromMinutes(value: number, returnsNullWhenInvalid: true): TimeObject | null;
2031
+
2032
+ /**
2033
+ * Returns the number of seconds since the Unix epoch (January 1, 1970).
2034
+ *
2035
+ * This function accepts either a `Date` object or a timestamp in milliseconds (number).
2036
+ * If no argument is provided, it defaults to the current timestamp in seconds.
2037
+ *
2038
+ * @param {Date | number} [fromValue=Date.now()] - The date or timestamp to convert.
2039
+ * If not provided, the current date and time will be used.
2040
+ *
2041
+ * @returns {number} The number of seconds since the Unix epoch for the provided date or timestamp.
2042
+ *
2043
+ * @example
2044
+ * // Using a Date object
2045
+ * const date = new Date('2020-01-01T00:00:00Z');
2046
+ * console.log(timestamp(date)); // Returns 1577836800 (seconds since Unix epoch)
2047
+ *
2048
+ * // Using a timestamp in milliseconds
2049
+ * const timestampInMs = 1609459200000;
2050
+ * console.log(timestamp(timestampInMs)); // Returns 1609459200 (seconds since Unix epoch)
2051
+ *
2052
+ * // Using the current time
2053
+ * console.log(timestamp()); // Returns current seconds since Unix epoch
2054
+ *
2055
+ * @group Date
2056
+ */
2057
+ declare function timestamp(fromValue?: Date | number): number;
2058
+
2059
+ /**
2060
+ * Converts a Unix timestamp (in seconds) to a `Date` object.
2061
+ *
2062
+ * This function accepts a timestamp in seconds (number) and returns a `Date` object
2063
+ * corresponding to that timestamp. If an invalid number is passed (non-numeric or NaN),
2064
+ * it returns `null`.
2065
+ *
2066
+ * @param {number} value - The Unix timestamp (in seconds) to convert into a `Date` object.
2067
+ * @returns {Date | null} The `Date` object corresponding to the provided timestamp, or `null`
2068
+ * if the value is not a valid number.
2069
+ *
2070
+ * @example
2071
+ * const date = timestampToDate(1609459200);
2072
+ * console.log(date); // Outputs: Thu Jan 01 2021 00:00:00 GMT+0000 (UTC)
2073
+ *
2074
+ * // Invalid input
2075
+ * console.log(timestampToDate('invalid')); // Outputs: null
2076
+ * console.log(timestampToDate(NaN)); // Outputs: null
2077
+ * console.log(timestampToDate(null)); // Outputs: null
2078
+ *
2079
+ * @group Date
2080
+ */
2081
+ declare function timestampToDate(value: number): Date | null;
2082
+
2083
+ declare function timeStringify(value: TimeValue): string;
2084
+ declare function timeStringify(value: TimeValue, returnsNullWhenInvalid: true): string | null;
2085
+
2086
+ /**
2087
+ * Converts a time value into the total number of minutes.
2088
+ *
2089
+ * @param {TimeValue} value - A time value
2090
+ *
2091
+ * @returns {number} The total number of minutes represented by the time value.
2092
+ *
2093
+ * @example
2094
+ * // Assuming createTimeObject("2:30") returns { h: 2, m: 30 }
2095
+ * timeToMinutes("2:30"); // 150
2096
+ *
2097
+ * // Assuming createTimeObject({ h: 1, m: 45 }) returns { h: 1, m: 45 }
2098
+ * timeToMinutes({ h: 1, m: 45 }); // 105
2099
+ *
2100
+ * @group Date
2101
+ */
2102
+ declare function timeToMinutes(value: TimeValue): number;
2103
+
2104
+ /**
2105
+ * Determines the number of ISO weeks in a given year.
2106
+ *
2107
+ * The ISO week numbering system defines a year as having 52 or 53 full weeks.
2108
+ *
2109
+ * @param {number} year - The year for which to calculate the number of ISO weeks.
2110
+ * @returns {number} - Returns 52 or 53 based on the ISO 8601 standard.
2111
+ *
2112
+ * @example
2113
+ * // Common year with 52 weeks
2114
+ * weeksInYear(2023); // 52
2115
+ *
2116
+ * @example
2117
+ * // Leap year with 53 weeks
2118
+ * weeksInYear(2020); // 53
2119
+ *
2120
+ * @group Date
2121
+ */
2122
+ declare function weeksInYear(year: number): number;
2123
+
2124
+ type EJSONType = {
2125
+ /**
2126
+ * The string placeholder (must start with `$`) that represents the custom type.
2127
+ */
2128
+ placeholder: string;
2129
+ /**
2130
+ * Should encoded value inlined to original key
2131
+ */
2132
+ encodeInline?: boolean;
2133
+ /**
2134
+ * Function to encode a value into a custom representation using a custom type handler.
2135
+ *
2136
+ * If the function returns `undefined`, it signals that encoding for this value should
2137
+ * be delegated to another type handler or encoding logic.
2138
+ *
2139
+ * @param {any} value - The value to be encoded.
2140
+ * @param {(value: any) => any} encode - A reference to the general encoding function
2141
+ * (useful for recursive encoding logic if necessary).
2142
+ * @returns {any} - The custom-encoded value or `undefined` to delegate encoding to another type handler.
2143
+ */
2144
+ encode: (value: any, encode: (value: any) => any) => any;
2145
+ /**
2146
+ * A function to decode a custom representation back into a valid JavaScript value.
2147
+ */
2148
+ decode: (value: any) => any;
2149
+ };
2150
+ /**
2151
+ * EJSON - Extended JSON handler class for custom encoding and decoding with vendor support.
2152
+ * This class provides methods to encode, decode, stringify, and parse JSON with custom type handlers.
2153
+ */
2154
+ declare class EJSON {
2155
+ /** @internal */
2156
+ protected typeHandlers: Map<string, Readonly<EJSONType>>;
2157
+ /** @internal */
2158
+ protected replacerReady: (value: any, key: string) => any;
2159
+ /** @internal */
2160
+ protected encode: (value: any) => any;
2161
+ /** @internal */
2162
+ protected reviewerReady: (_: string, value: any) => any;
2163
+ /** @internal */
2164
+ protected pure: boolean;
2165
+ protected _vendorName: string | null;
2166
+ /**
2167
+ * MIME type based on the provided vendor name or defaults to 'application/json'.
2168
+ */
2169
+ mimetype: string;
2170
+ readonly Type: {
2171
+ readonly Date: EJSONType;
2172
+ readonly Map: EJSONType;
2173
+ readonly Set: EJSONType;
2174
+ readonly RegExp: EJSONType;
2175
+ readonly Infinity: EJSONType;
2176
+ readonly BigInt: EJSONType;
2177
+ readonly Binary: EJSONType;
2178
+ };
2179
+ constructor();
2180
+ /**
2181
+ * The vendor name used for the custom MIME type definition.
2182
+ * If null, defaults to 'application/json'.
2183
+ */
2184
+ get vendorName(): string | null;
2185
+ set vendorName(value: string | null);
2186
+ /**
2187
+ * Adds a custom type handler for encoding/decoding logic.
2188
+ * Ensures type placeholders are unique and adhere to conventions.
2189
+ */
2190
+ addType(type: Readonly<EJSONType>): this;
2191
+ /**
2192
+ * Stringifies a JavaScript value using custom encoding logic.
2193
+ * @param {any} value - The value to encode and stringify.
2194
+ * @param {string | number} [space] - Optional space for pretty-printing.
2195
+ * @returns {string} - The JSON stringified value.
2196
+ */
2197
+ stringify(value: any, space?: string | number): string;
2198
+ /**
2199
+ * Parses a JSON string using custom decoding logic.
2200
+ * @param {string} value - The JSON string to parse.
2201
+ * @returns {any} - The decoded JavaScript object.
2202
+ */
2203
+ parse(value: string): any;
2204
+ /** @internal */
2205
+ protected _replacer(value: any, key: string): any;
2206
+ /** @internal */
2207
+ protected _reviewer(_: string, value: any): any;
2208
+ }
2209
+
2210
+ /**
2211
+ * Creates a new instance of the `EJSON` (Extensible JSON) with optional basic types pre-registered.
2212
+ *
2213
+ * This function allows you to initialize an `EJSON` instance with commonly used types like `Map`, `Set`,
2214
+ * `Date`, `RegExp`, `Infinity`, `BigInt` and `Uint8Array`. These types are added to the type handlers only when `withBasicTypes` is set to `true`.
2215
+ *
2216
+ * | Type | Placeholder | Alias |
2217
+ * |-------------|-------------|----------------|
2218
+ * | Date | $date | EJSON.Date |
2219
+ * | Map | $map | EJSON.Map |
2220
+ * | Set | $set | EJSON.Set |
2221
+ * | Infinity | $inf | EJSON.Infinity |
2222
+ * | BigInt | $bigint | EJSON.BigInt |
2223
+ * | RegExp | $regexp | EJSON.RegExp |
2224
+ * | Uint8Array | $binary | EJSON.Binary |
2225
+ * | Uint16Array | $binary | EJSON.Binary |
2226
+ * | Uint32Array | $binary | EJSON.Binary |
2227
+ *
2228
+ * @param {boolean} [withBasicTypes=false] - Indicates whether to include basic types like Map, Set, Date, and BigInt.
2229
+ * @returns {EJSON} - A new instance of the `EJSON` class configured with optional basic types.
2230
+ *
2231
+ * @example
2232
+ * // Instance with basic types (Map, Set, Date, BigInt, Uint8Array)
2233
+ * import { EJSON } from '@andrew_l/toolkit';
2234
+ *
2235
+ * EJSON.stringify({ value: new Date(0) });
2236
+ * // {"value":{"$date": 0}}
2237
+ *
2238
+ * @example
2239
+ * // Create an EJSON instance without any additional types
2240
+ * const ejson = createEJSON();
2241
+ *
2242
+ * ejson.stringify({ value: new Date(0) });
2243
+ * // {"value":"1970-01-01T00:00:00.000Z"}
2244
+ *
2245
+ * @example
2246
+ * // Custom type
2247
+ * import { EJSON, createEJSON } from '@andrew_l/toolkit';
2248
+ *
2249
+ * const ejson = createEJSON();
2250
+ *
2251
+ * ejson.vendorName = 'Andrew';
2252
+ *
2253
+ * // Add pre-build date type
2254
+ * ejson.addType(EJSON.Date);
2255
+ *
2256
+ * // Add custom buffer type
2257
+ * ejson.addType({
2258
+ * placeholder: '$buffer',
2259
+ * encode(value) {
2260
+ * if (Buffer.isBuffer(value)) {
2261
+ * return value.toString('hex');
2262
+ * }
2263
+ * },
2264
+ * decode(value) {
2265
+ * return Buffer.from(value, 'hex');
2266
+ * }
2267
+ * });
2268
+ *
2269
+ * ejson.stringify({
2270
+ * value: [
2271
+ * Buffer.from('Hello World', 'utf8'),
2272
+ * new Date(0)
2273
+ * ]
2274
+ * });
2275
+ * // {"value":[{"$buffer":"48656c6c6f20576f726c64"},{"$date":0}]}
2276
+ *
2277
+ * console.log(ejson.mimetype); // application/vnd.andrew+json
2278
+ *
2279
+ * @group EJSON
2280
+ */
2281
+ declare function createEJSON(withBasicTypes?: boolean): EJSON;
2282
+
2283
+ interface EJSONStreamOptions {
2284
+ /**
2285
+ * EJSON Instance
2286
+ */
2287
+ ejson: EJSON;
2288
+ /**
2289
+ * Starting encoding symbol
2290
+ */
2291
+ op: string;
2292
+ /**
2293
+ * Separator symbol
2294
+ */
2295
+ sep: string;
2296
+ /**
2297
+ * Ending symbol
2298
+ */
2299
+ cl: string;
2300
+ /** @internal */
2301
+ onStart?: (controller: TransformStreamDefaultController) => Promise<void>;
2302
+ /** @internal */
2303
+ onFlush?: (controller: TransformStreamDefaultController) => Promise<void>;
2304
+ }
2305
+ declare class EJSONStream extends TransformStream<any, string> {
2306
+ protected ejson: EJSON;
2307
+ constructor({ ejson, cl, op, sep, onFlush, onStart }: EJSONStreamOptions);
2308
+ /**
2309
+ * The vendor name used for the custom MIME type definition.
2310
+ * If null, defaults to 'application/json'.
2311
+ */
2312
+ get vendorName(): string | null;
2313
+ /**
2314
+ * MIME type based on the provided vendor name or defaults to 'application/json'.
2315
+ */
2316
+ get mimetype(): string;
2317
+ }
2318
+
2319
+ interface EJSONStreamOptionsWithPayload extends Partial<EJSONStreamOptions> {
2320
+ prepend?: () => Awaitable<object | null | undefined>;
2321
+ append?: () => Awaitable<object | null | undefined>;
2322
+ resultKey: string;
2323
+ }
2324
+ /**
2325
+ * Creates an instance of `EJSONStream`. This function provides flexibility to create a simple stream
2326
+ * or one with custom payload transformations, such as appending or prepending data.
2327
+ *
2328
+ * The function has overloads to handle either basic streaming options or more advanced use cases
2329
+ * with payload functions (`append`, `prepend`, `resultKey`) to modify how JSON payloads are streamed.
2330
+ *
2331
+ * @function
2332
+ * @param {Partial<EJSONStreamOptions> | EJSONStreamOptionsWithPayload} [options] - Options to configure the EJSONStream.
2333
+ * @returns {EJSONStream} An instance of the `EJSONStream`.
2334
+ *
2335
+ * @example
2336
+ * // Example 1: Create a simple EJSONStream without custom payload transformations
2337
+ * const stream = createEJSONStream();
2338
+ *
2339
+ * @example
2340
+ * // Example 2: Create EJSONStream with specific options
2341
+ * const stream = createEJSONStream({
2342
+ * cl: ']',
2343
+ * op: '[',
2344
+ * sep: ',',
2345
+ * ejson: someInstance
2346
+ * });
2347
+ *
2348
+ * @example
2349
+ * // Example 3: Using prepend and append payloads
2350
+ * const streamWithPayloads = createEJSONStream({
2351
+ * prepend: async () => ({ key1: 'value1' }),
2352
+ * append: async () => ({ key2: 'value2' }),
2353
+ * resultKey: 'payload'
2354
+ * });
2355
+ *
2356
+ * // {"key1":"value1","payload": [...data],"key2":"value2"}
2357
+ *
2358
+ * @group EJSON
2359
+ */
2360
+ declare function createEJSONStream(options?: Partial<EJSONStreamOptions>): EJSONStream;
2361
+ declare function createEJSONStream(options: EJSONStreamOptionsWithPayload): EJSONStream;
2362
+
2363
+ declare const instance: EJSON;
2364
+
2365
+ type Dict<T> = {
2366
+ [key: string]: T | undefined;
2367
+ };
2368
+ type ListTypeName = 'bool' | 'int' | 'decimal' | 'string';
2369
+ type ListTypeNameToType<T extends ListTypeName> = T extends 'bool' ? boolean : T extends 'int' ? number : T extends 'decimal' ? number : T extends 'string' ? string : never;
2370
+ /**
2371
+ * Environment variable parser
2372
+ *
2373
+ * @group Environment
2374
+ */
2375
+ interface EnvParser {
2376
+ /**
2377
+ * NODE_ENV is `development`
2378
+ */
2379
+ isDevelopment: boolean;
2380
+ /**
2381
+ * NODE_ENV is `production`
2382
+ */
2383
+ isProduction: boolean;
2384
+ /**
2385
+ * NODE_ENV is `stage`
2386
+ */
2387
+ isStage: boolean;
2388
+ /**
2389
+ * NODE_ENV is `test`
2390
+ */
2391
+ isTest: boolean;
2392
+ /**
2393
+ * Returns `true` when environment key has set to `"true"`
2394
+ *
2395
+ * Returns `defaultValue` when key is not defined
2396
+ */
2397
+ bool(key: string, defaultValue?: boolean): boolean;
2398
+ /**
2399
+ * Returns `number` when environment key has correct number value.
2400
+ *
2401
+ * Returns `defaultValue` when environment key is not defined or has invalid number value
2402
+ */
2403
+ int(key: string, defaultValue?: number): number;
2404
+ /**
2405
+ * Returns `number` when environment key has correct number value.
2406
+ *
2407
+ * Returns `defaultValue` when environment key is not defined or has invalid number value
2408
+ */
2409
+ decimal(key: string, dights?: number, defaultValue?: number): number;
2410
+ /**
2411
+ * Returns `string` when environment key has defined.
2412
+ *
2413
+ * Returns `defaultValue` when environment key is not defined
2414
+ */
2415
+ string(key: string, defaultValue?: string): string;
2416
+ /**
2417
+ * Returns `array` of parsed environment value.
2418
+ *
2419
+ * Returns `defaultValue` when key is not defined
2420
+ */
2421
+ list<T extends ListTypeName>(key: string, itemType: T, defaultValue?: ListTypeNameToType<T>[]): ListTypeNameToType<T>[];
2422
+ /**
2423
+ * Returns parsed json value.
2424
+ *
2425
+ * Returns `defaultValue` when key is not defined or invalid json value
2426
+ */
2427
+ json<T = any>(key: string, defaultValue?: T | null): T | null;
2428
+ }
2429
+ /**
2430
+ * Ready-to-use environment parser.
2431
+ *
2432
+ * Target: `process.env`
2433
+ *
2434
+ * Fallback: `import.meta.env`
2435
+ *
2436
+ * @example
2437
+ *
2438
+ * // env.string
2439
+ * const API_KEY = env.string('API_KEY', 'test_key');
2440
+ *
2441
+ * // env.bool
2442
+ * const TEST_FEATURE = env.bool('TEST_FEATURE', false);
2443
+ *
2444
+ * // env.int
2445
+ * const RETRY_ATTEMPTS = env.int('RETRY_ATTEMPTS', 5);
2446
+ *
2447
+ * // env.decimal
2448
+ * const DELAY_SECONDS = env.decimal('DELAY_SECONDS', 2, 5); // round to 2 dights
2449
+ *
2450
+ * // env.list
2451
+ * const TARGET_ROLES = env.list('TARGET_ROLES', 'string', ['ADMIN']);
2452
+ *
2453
+ * // env.json
2454
+ * const GOOGLE_CREDS = env.json<{ projectId: string; token: string; }>('GOOGLE_CREDS');
2455
+ *
2456
+ * @group Environment
2457
+ */
2458
+ declare const env: Readonly<EnvParser>;
2459
+ /**
2460
+ * @example
2461
+ * const env = createEnvParser(process.env);
2462
+ * // const env = createEnvParser(import.meta.env);
2463
+ *
2464
+ * const API_KEY = env.string('API_KEY', 'test_key');
2465
+ *
2466
+ * @group Environment
2467
+ */
2468
+ declare function createEnvParser(targetObject: Record<string, string> | Dict<string>): Readonly<EnvParser>;
2469
+
2470
+ /**
2471
+ * Simple application error class with the code
2472
+ * @group Errors
1250
2473
  */
1251
2474
  declare class AppError extends Error {
1252
2475
  code: number;
@@ -1374,16 +2597,32 @@ declare const isFunction: <T extends Function>(val: any) => val is T;
1374
2597
  * @group Predicates
1375
2598
  */
1376
2599
  declare const isNumber: (val: any) => val is number;
2600
+ /**
2601
+ * Checks if the given value is a `Infinity` number.
2602
+ *
2603
+ * @example
2604
+ * console.log(isInfinity(123)); // false
2605
+ * console.log(isNumber(Infinity)); // true
2606
+ * console.log(isNumber(-Infinity)); // true
2607
+ *
2608
+ * @group Predicates
2609
+ */
2610
+ declare const isInfinity: (val: any) => val is number;
1377
2611
  /**
1378
2612
  * Checks if the given value is a `string`
1379
2613
  * @group Predicates
1380
2614
  */
1381
2615
  declare const isString: (val: unknown) => val is string;
1382
2616
  /**
1383
- * Checks if the given value is a plain `object`
2617
+ * Checks if the given value is a `object`
1384
2618
  * @group Predicates
1385
2619
  */
1386
2620
  declare const isObject: (val: any) => val is object;
2621
+ /**
2622
+ * Checks if the given value is a plain `object`
2623
+ * @group Predicates
2624
+ */
2625
+ declare const isPlainObject: (val: any) => val is object;
1387
2626
  /**
1388
2627
  * Checks if the given value is valid `Date`
1389
2628
  * @group Predicates
@@ -1956,57 +3195,6 @@ declare function percentOf(value: number, percent: number, digits?: number): num
1956
3195
  */
1957
3196
  declare function round2digits(value: number, digits?: number): number;
1958
3197
 
1959
- /**
1960
- * Returns the number of seconds since the Unix epoch (January 1, 1970).
1961
- *
1962
- * This function accepts either a `Date` object or a timestamp in milliseconds (number).
1963
- * If no argument is provided, it defaults to the current timestamp in seconds.
1964
- *
1965
- * @param {Date | number} [fromValue=Date.now()] - The date or timestamp to convert.
1966
- * If not provided, the current date and time will be used.
1967
- *
1968
- * @returns {number} The number of seconds since the Unix epoch for the provided date or timestamp.
1969
- *
1970
- * @example
1971
- * // Using a Date object
1972
- * const date = new Date('2020-01-01T00:00:00Z');
1973
- * console.log(timestamp(date)); // Returns 1577836800 (seconds since Unix epoch)
1974
- *
1975
- * // Using a timestamp in milliseconds
1976
- * const timestampInMs = 1609459200000;
1977
- * console.log(timestamp(timestampInMs)); // Returns 1609459200 (seconds since Unix epoch)
1978
- *
1979
- * // Using the current time
1980
- * console.log(timestamp()); // Returns current seconds since Unix epoch
1981
- *
1982
- * @group Numbers
1983
- */
1984
- declare function timestamp(fromValue?: Date | number): number;
1985
-
1986
- /**
1987
- * Converts a Unix timestamp (in seconds) to a `Date` object.
1988
- *
1989
- * This function accepts a timestamp in seconds (number) and returns a `Date` object
1990
- * corresponding to that timestamp. If an invalid number is passed (non-numeric or NaN),
1991
- * it returns `null`.
1992
- *
1993
- * @param {number} value - The Unix timestamp (in seconds) to convert into a `Date` object.
1994
- * @returns {Date | null} The `Date` object corresponding to the provided timestamp, or `null`
1995
- * if the value is not a valid number.
1996
- *
1997
- * @example
1998
- * const date = timestampToDate(1609459200);
1999
- * console.log(date); // Outputs: Thu Jan 01 2021 00:00:00 GMT+0000 (UTC)
2000
- *
2001
- * // Invalid input
2002
- * console.log(timestampToDate('invalid')); // Outputs: null
2003
- * console.log(timestampToDate(NaN)); // Outputs: null
2004
- * console.log(timestampToDate(null)); // Outputs: null
2005
- *
2006
- * @group Numbers
2007
- */
2008
- declare function timestampToDate(value: number): Date | null;
2009
-
2010
3198
  /**
2011
3199
  * Removes properties with empty values from an object.
2012
3200
  *
@@ -3152,7 +4340,7 @@ type RetryOnErrorConfig = {
3152
4340
  /**
3153
4341
  * Error validation function. If returns true, the main callback's considered ready to be executed again
3154
4342
  */
3155
- shouldRetryBasedOnError: (error: unknown, attempt: number) => boolean;
4343
+ shouldRetryBasedOnError?: (error: unknown, attempt: number) => boolean;
3156
4344
  /**
3157
4345
  * Number of retries until the execution fails
3158
4346
  */
@@ -3186,7 +4374,7 @@ type RetryOnErrorConfig = {
3186
4374
  *
3187
4375
  * @group Errors
3188
4376
  */
3189
- declare function retryOnError<T extends AnyFunction>({ beforeRetryCallback, maxRetriesNumber, shouldRetryBasedOnError, delayFactor, delayMaxMs, delayMinMs, }: RetryOnErrorConfig, fn: T): (...args: Parameters<T>) => Promise<Awaited<ReturnType<T>>>;
4377
+ declare function retryOnError<T extends AnyFunction>({ beforeRetryCallback, shouldRetryBasedOnError, maxRetriesNumber, delayFactor, delayMaxMs, delayMinMs, }: RetryOnErrorConfig, fn: T): (...args: Parameters<T>) => Promise<Awaited<ReturnType<T>>>;
3190
4378
 
3191
4379
  /**
3192
4380
  * Converts a string to camel case.
@@ -3722,4 +4910,4 @@ declare function wrapText(value: string, maxLength?: number): string;
3722
4910
  */
3723
4911
  declare function toError<T>(value: T, unknownMessage?: string): T extends Error ? T : Error;
3724
4912
 
3725
- export { type AnyFunction, AppError, type ArgumentsType, type Arrayable, AsyncIterableQueue, type Awaitable, BrowserAssertionError, CancellablePromise, Color, type ColorChannels, ColorParser, type Data, type DeepPartial, type Defer, type EnvParser, type ExecResult, type ExecResultToSkip, type ExecResultToSuccess, type ExecSkip, type ExecSuccess, FixedMap, FixedWeakMap, type Fn, type FormatMoney, type FormatNumber, type FunctionArgs, type GenericObject, type IfAny, type IsAny, type LiteralUnion, type Logger, LruCache, type Nothing, type OverwriteWith, type Prettify, type Primitive, type PromisifyFn, Queue, type RandomizerOptions, type RetryOnErrorConfig, type SelectOptionItem, type SelectOptions, type SimpleDefaultEventMap, SimpleEventEmitter, type SimpleEventMap, _default as TWEMOJI_REGEX, type ThemeConfig, TimeBucket, type TimeBucketOptions, type TimeObject, type TypeOf, type TypeOfMap, type ValuesOfObject, type WithCache, type WithCacheBucketBatchOptions, type WithCacheBucketOptions, type WithCacheFixedOptions, type WithCacheLruOptions, type WithCacheOptions, type WithCachePointer, type WithCacheResult, type WithCacheStorage, type WithCustomizer, type WithCustomizerFactory, type WithCustomizerValue, alpha, arrayable, assert, asyncFilter, asyncFind, asyncForEach, asyncMap, avg, blendColors, buildCssColor, cache, cacheBucket, cacheFixed, cacheLRU, camelCase, capitalize, captureStackTrace, catchError, channelsToHSL, channelsToHex, channelsToRGB, checkBitmask, chunk, chunkSeries, clamp, cleanEmpty, cleanObject, colorToChannels, contrastRatio, convertToUnit, crc32, createCustomizer, createCustomizerFactory, createDeepCloneWith, createEnvParser, createRandomizer, createSecureCustomizer, createWithCache, cssVariable, deepAssign, deepClone, deepCloneWith, deepDefaults, deepFreeze, def, defer, delay, dropCache, env, escapeHtml, escapeNumeric, escapeRegExp, fastIdle, fastIdlePromise, fastRaf, findMean, flagsToMap, flatten, formatMoney, formatNumber, get, getFileExtension, getFileName, getInitials, getRandomInt, getWords, has, hasOwn, hasProtocol, hex, hexToChannels, hslToChannels, humanFileSize, humanize, interpolateColor, isBigInt, isBoolean, isCached, isClient, isColorChannels, isCustomizerFactory, isDate, isDef, isEmpty, isEqual, isError, isFunction, isMap, isNullOrUndefined, isNumber, isObject, isOneEmoji, isPrimitive, isPromise, isSet, isSkip, isString, isSuccess, isSymbol, isWeakMap, isWeakSet, isWithCache, isoToFlagEmoji, kebabCase, keyBy, logger, lowerCase, luminance, maskingEmail, maskingPhone, maskingWords, nextTickIteration, noop, objectId, omit, omitPrefixed, orderBy, parseAllNumbers, parseAlpha, parsePercentage, percentOf, pick, pickPrefixed, qs, rafPromise, randomString, removeVS16s, retryOnError, rgbToChannels, round2digits, set, snakeCase, sprintf, startCase, strAssign, sum, timeout, timestamp, timestampToDate, tintedTextColor, toError, toMap, truncate, typeOf, unflatten, union, uniq, uniqBy, unset, withCache, withCacheBucket, withCacheBucketBatch, withCacheFixed, withCacheLRU, withDeepClone, withPointerCache, wrapText };
4913
+ export { type AnyFunction, AppError, type ArgumentsType, type Arrayable, AsyncIterableQueue, type Awaitable, type Base64ToBytesOptions, BrowserAssertionError, type BytesToBase64Options, CancellablePromise, type CatchErrorResult, Color, type ColorChannels, ColorParser, type Data, type DateObject, type DateObjectInput, type DeepPartial, type Defer, instance as EJSON, EJSONStream, type EJSONStreamOptions, type EJSONStreamOptionsWithPayload, type EnvParser, type ExecResult, type ExecResultToSkip, type ExecResultToSuccess, type ExecSkip, type ExecSuccess, FindMean, FixedMap, FixedWeakMap, type Fn, type FormatMoney, type FormatNumber, type FunctionArgs, type GenericObject, type IfAny, type IsAny, type LiteralUnion, type Logger, LruCache, type Nothing, type OverwriteWith, type Prettify, type Primitive, type PromisifyFn, Queue, type RandomizerOptions, type RetryOnErrorConfig, type SelectOptionItem, type SelectOptions, type SimpleDefaultEventMap, SimpleEventEmitter, type SimpleEventMap, _default as TWEMOJI_REGEX, type ThemeConfig, TimeBucket, type TimeBucketOptions, type TimeObject, type TimeObjectInput, TimeSpan, type TimeSpanUnit, type TimeString, type TimeValue, type TimestampMsInput, type TypeOf, type TypeOfMap, type ValuesOfObject, type WithCache, type WithCacheBucketBatchOptions, type WithCacheBucketOptions, type WithCacheFixedOptions, type WithCacheLruOptions, type WithCacheOptions, type WithCachePointer, type WithCacheResult, type WithCacheStorage, type WithCustomizer, type WithCustomizerFactory, type WithCustomizerValue, alpha, arrayable, assert, asyncFilter, asyncFind, asyncForEach, asyncMap, avg, base64ToBytes, bigIntBytes, bigIntFromBytes, blendColors, buildCssColor, bytesToBase64, cache, cacheBucket, cacheFixed, cacheLRU, camelCase, capitalize, captureStackTrace, catchError, channelsToHSL, channelsToHex, channelsToRGB, checkBitmask, chunk, chunkSeries, clamp, cleanEmpty, cleanObject, colorToChannels, compareBytes, concatenateBytes, contrastRatio, convertToUnit, crc32, createCustomizer, createCustomizerFactory, createDateObject, createDeepCloneWith, createEJSON, createEJSONStream, createEnvParser, createRandomizer, createSecureCustomizer, createTimeObject, createTimeSpan, createWithCache, cssVariable, dateInDays, dateInSeconds, deepAssign, deepClone, deepCloneWith, deepDefaults, deepFreeze, def, defer, delay, difference, dropCache, env, escapeHtml, escapeNumeric, escapeRegExp, fastIdle, fastIdlePromise, fastRaf, findMean, flagsToMap, flatten, formatMoney, formatNumber, get, getFileExtension, getFileName, getInitials, getRandomInt, getRandomTime, getWords, has, hasOwn, hasProtocol, hex, hexToChannels, hmToSeconds, hslToChannels, humanFileSize, humanize, interpolateColor, intersection, isBigInt, isBoolean, isCached, isClient, isColorChannels, isCustomizerFactory, isDate, isDateObject, isDef, isEmpty, isEqual, isError, isFunction, isInfinity, isMap, isNullOrUndefined, isNumber, isObject, isOneEmoji, isPlainObject, isPrimitive, isPromise, isSet, isSkip, isString, isSuccess, isSymbol, isTimeObject, isTimeString, isTimeValue, isValidWeekDay, isWeakMap, isWeakSet, isWithCache, isoToFlagEmoji, kebabCase, keyBy, logger, lowerCase, luminance, maskingEmail, maskingPhone, maskingWords, nextTickIteration, noop, objectId, omit, omitPrefixed, orderBy, parseAllNumbers, parseAlpha, parsePercentage, percentOf, pick, pickPrefixed, qs, rafPromise, randomString, removeVS16s, retryOnError, rgbToChannels, round2digits, secondsToHm, set, shuffle, snakeCase, sprintf, startCase, strAssign, sum, timeFromMinutes, timeStringify, timeToMinutes, timeout, timestamp, timestampMs, timestampToDate, tintedTextColor, toError, toMap, truncate, typeOf, uint16ToUint8, uint32ToUint8, uint8ToUint16, uint8ToUint32, unflatten, union, uniq, uniqBy, unset, weeksInYear, withCache, withCacheBucket, withCacheBucketBatch, withCacheFixed, withCacheLRU, withDeepClone, withPointerCache, wrapText };