@oscarpalmer/atoms 0.77.0 → 0.77.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (54) hide show
  1. package/dist/js/array/chunk.cjs +1 -1
  2. package/dist/js/array/chunk.js +1 -1
  3. package/dist/js/value/equal.cjs +4 -1
  4. package/dist/js/value/equal.js +4 -1
  5. package/package.json +1 -1
  6. package/src/js/array/chunk.ts +1 -1
  7. package/src/js/array/count.ts +6 -6
  8. package/src/js/array/exists.ts +6 -6
  9. package/src/js/array/filter.ts +6 -6
  10. package/src/js/array/find.ts +6 -6
  11. package/src/js/array/group-by.ts +67 -55
  12. package/src/js/array/index-of.ts +6 -6
  13. package/src/js/array/sort.ts +20 -0
  14. package/src/js/array/to-map.ts +55 -47
  15. package/src/js/array/to-record.ts +61 -57
  16. package/src/js/array/unique.ts +6 -6
  17. package/src/js/internal/value/handle.ts +5 -5
  18. package/src/js/value/clone.ts +3 -1
  19. package/src/js/value/equal.ts +4 -1
  20. package/src/js/value/get.ts +9 -9
  21. package/src/js/value/set.ts +10 -11
  22. package/types/array/count.d.cts +34 -2
  23. package/types/array/count.d.ts +3 -3
  24. package/types/array/exists.d.cts +34 -2
  25. package/types/array/exists.d.ts +3 -3
  26. package/types/array/filter.d.cts +34 -2
  27. package/types/array/filter.d.ts +3 -3
  28. package/types/array/find.d.cts +34 -2
  29. package/types/array/find.d.ts +3 -3
  30. package/types/array/group-by.d.cts +44 -12
  31. package/types/array/group-by.d.ts +14 -14
  32. package/types/array/index-of.d.cts +34 -2
  33. package/types/array/index-of.d.ts +3 -3
  34. package/types/array/index.d.cts +88 -46
  35. package/types/array/sort.d.cts +42 -0
  36. package/types/array/sort.d.ts +11 -1
  37. package/types/array/to-map.d.cts +42 -10
  38. package/types/array/to-map.d.ts +13 -13
  39. package/types/array/to-record.d.cts +44 -12
  40. package/types/array/to-record.d.ts +13 -13
  41. package/types/array/unique.d.cts +34 -2
  42. package/types/array/unique.d.ts +3 -3
  43. package/types/index.d.cts +1034 -317
  44. package/types/internal/value/handle.d.cts +27 -2
  45. package/types/internal/value/handle.d.ts +2 -2
  46. package/types/models.d.cts +467 -210
  47. package/types/value/clone.d.cts +1 -1
  48. package/types/value/clone.d.ts +1 -1
  49. package/types/value/get.d.cts +470 -211
  50. package/types/value/get.d.ts +3 -3
  51. package/types/value/index.d.cts +515 -224
  52. package/types/value/set.d.cts +357 -170
  53. package/types/value/set.d.ts +3 -3
  54. package/types/value/smush.d.cts +463 -209
package/types/index.d.cts CHANGED
@@ -5,7 +5,10 @@
5
5
  * - Maximum size defaults to _2^20_; any provided size will be clamped at _2^24_
6
6
  * - Behaviour is similar to a _LRU_-cache, where the least recently used entries are removed
7
7
  */
8
- export declare class SizedMap<Key = unknown, Value = unknown> extends Map<Key, Value> {
8
+ export declare class SizedMap<Key = unknown, Value = unknown> extends Map<
9
+ Key,
10
+ Value
11
+ > {
9
12
  private readonly maximumSize;
10
13
  /**
11
14
  * Is the Map full?
@@ -18,10 +21,7 @@ export declare class SizedMap<Key = unknown, Value = unknown> extends Map<Key, V
18
21
  /**
19
22
  * Create a new Map with entries and a maximum size _(2^20)_
20
23
  */
21
- constructor(entries: Array<[
22
- Key,
23
- Value
24
- ]>);
24
+ constructor(entries: Array<[Key, Value]>);
25
25
  /**
26
26
  * Create a new Map with a maximum size _(but clamped at 2^24)_
27
27
  */
@@ -29,10 +29,7 @@ export declare class SizedMap<Key = unknown, Value = unknown> extends Map<Key, V
29
29
  /**
30
30
  * Create a new Map with _(optional)_ entries and a maximum size _(defaults to 2^20; clamped at 2^24)_
31
31
  */
32
- constructor(entries?: Array<[
33
- Key,
34
- Value
35
- ]>, maximum?: number);
32
+ constructor(entries?: Array<[Key, Value]>, maximum?: number);
36
33
  /**
37
34
  * @inheritdoc
38
35
  */
@@ -92,7 +89,10 @@ export declare function getRandomBoolean(): boolean;
92
89
  * Get a random string of characters with a specified length
93
90
  * - `selection` defaults to all lowercase letters in the English alphabet
94
91
  */
95
- export declare function getRandomCharacters(length: number, selection?: string): string;
92
+ export declare function getRandomCharacters(
93
+ length: number,
94
+ selection?: string,
95
+ ): string;
96
96
  /**
97
97
  * Get a random hexadecimal colour
98
98
  */
@@ -117,7 +117,10 @@ export declare function getRandomItem<Value>(array: Value[]): Value;
117
117
  * - Get an amount of random items from an array
118
118
  * - If `amount` is not specified, a shuffled array will be returned instead
119
119
  */
120
- export declare function getRandomItems<Value>(array: Value[], amount?: number): Value[];
120
+ export declare function getRandomItems<Value>(
121
+ array: Value[],
122
+ amount?: number,
123
+ ): Value[];
121
124
  /**
122
125
  * Queue a callback to be executed at the next best time
123
126
  */
@@ -127,7 +130,14 @@ Matches any [primitive value](https://developer.mozilla.org/en-US/docs/Glossary/
127
130
 
128
131
  @category Type
129
132
  */
130
- export type Primitive = null | undefined | string | number | boolean | symbol | bigint;
133
+ export type Primitive =
134
+ | null
135
+ | undefined
136
+ | string
137
+ | number
138
+ | boolean
139
+ | symbol
140
+ | bigint;
131
141
  /**
132
142
  Create a union of all keys from a given type, even those exclusive to specific union members.
133
143
 
@@ -165,7 +175,9 @@ type AllKeys = KeysOfUnion<Union>;
165
175
 
166
176
  @category Object
167
177
  */
168
- export type KeysOfUnion<ObjectType> = ObjectType extends unknown ? keyof ObjectType : never;
178
+ export type KeysOfUnion<ObjectType> = ObjectType extends unknown
179
+ ? keyof ObjectType
180
+ : never;
169
181
  declare const emptyObjectSymbol: unique symbol;
170
182
  /**
171
183
  Represents a strictly empty plain object, the `{}` value.
@@ -222,7 +234,11 @@ type Includes<Value extends readonly any[], Item> =
222
234
  @category Type Guard
223
235
  @category Utilities
224
236
  */
225
- export type IsEqual<A, B> = (<G>() => G extends A ? 1 : 2) extends (<G>() => G extends B ? 1 : 2) ? true : false;
237
+ export type IsEqual<A, B> = (<G>() => G extends A ? 1 : 2) extends <
238
+ G,
239
+ >() => G extends B ? 1 : 2
240
+ ? true
241
+ : false;
226
242
  /**
227
243
  Represents an object with `unknown` value. You probably want this instead of `{}`.
228
244
 
@@ -349,14 +365,16 @@ type B = StaticPartOfArray<A>;
349
365
  //=> [string, number, boolean]
350
366
  ```
351
367
  */
352
- export type StaticPartOfArray<T extends UnknownArray, Result extends UnknownArray = [
353
- ]> = T extends unknown ? number extends T["length"] ? T extends readonly [
354
- infer U,
355
- ...infer V
356
- ] ? StaticPartOfArray<V, [
357
- ...Result,
358
- U
359
- ]> : Result : T : never; // Should never happen
368
+ export type StaticPartOfArray<
369
+ T extends UnknownArray,
370
+ Result extends UnknownArray = [],
371
+ > = T extends unknown
372
+ ? number extends T['length']
373
+ ? T extends readonly [infer U, ...infer V]
374
+ ? StaticPartOfArray<V, [...Result, U]>
375
+ : Result
376
+ : T
377
+ : never; // Should never happen
360
378
  /**
361
379
  Returns the variable, non-fixed-length portion of the given array, excluding static-length parts.
362
380
 
@@ -367,12 +385,22 @@ type B = VariablePartOfArray<A>;
367
385
  //=> string[]
368
386
  ```
369
387
  */
370
- export type VariablePartOfArray<T extends UnknownArray> = T extends unknown ? T extends readonly [
371
- ...StaticPartOfArray<T>,
372
- ...infer U
373
- ] ? U : [
374
- ] : never; // Should never happen
375
- export type StringDigit = "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9";
388
+ export type VariablePartOfArray<T extends UnknownArray> = T extends unknown
389
+ ? T extends readonly [...StaticPartOfArray<T>, ...infer U]
390
+ ? U
391
+ : []
392
+ : never; // Should never happen
393
+ export type StringDigit =
394
+ | '0'
395
+ | '1'
396
+ | '2'
397
+ | '3'
398
+ | '4'
399
+ | '5'
400
+ | '6'
401
+ | '7'
402
+ | '8'
403
+ | '9';
376
404
  /**
377
405
  Returns a boolean for whether the given type is `any`.
378
406
 
@@ -415,7 +443,7 @@ Please upvote [this issue](https://github.com/microsoft/TypeScript/issues/32277)
415
443
  */
416
444
  // See https://github.com/microsoft/TypeScript/issues/31752
417
445
  // eslint-disable-next-line @typescript-eslint/no-loss-of-precision
418
- export type PositiveInfinity = Infinity;
446
+ export type PositiveInfinity = 1e999;
419
447
  /**
420
448
  Matches the hidden `-Infinity` type.
421
449
 
@@ -427,7 +455,7 @@ Please upvote [this issue](https://github.com/microsoft/TypeScript/issues/32277)
427
455
  */
428
456
  // See https://github.com/microsoft/TypeScript/issues/31752
429
457
  // eslint-disable-next-line @typescript-eslint/no-loss-of-precision
430
- export type NegativeInfinity = -Infinity;
458
+ export type NegativeInfinity = -1e999;
431
459
  /**
432
460
  A negative `number`/`bigint` (`-∞ < x < 0`)
433
461
 
@@ -438,7 +466,11 @@ Use-case: Validating and documenting parameters.
438
466
 
439
467
  @category Numeric
440
468
  */
441
- export type Negative<T extends Numeric> = T extends Zero ? never : `${T}` extends `-${string}` ? T : never;
469
+ export type Negative<T extends Numeric> = T extends Zero
470
+ ? never
471
+ : `${T}` extends `-${string}`
472
+ ? T
473
+ : never;
442
474
  /**
443
475
  Returns a boolean for whether the given number is a negative number.
444
476
 
@@ -454,7 +486,9 @@ type ShouldBeTrue = IsNegative<-1>;
454
486
 
455
487
  @category Numeric
456
488
  */
457
- export type IsNegative<T extends Numeric> = T extends Negative<T> ? true : false;
489
+ export type IsNegative<T extends Numeric> = T extends Negative<T>
490
+ ? true
491
+ : false;
458
492
  /**
459
493
  Returns a boolean for whether two given types are both true.
460
494
 
@@ -475,11 +509,12 @@ And<true, false>;
475
509
  */
476
510
  export type And<A extends boolean, B extends boolean> = [
477
511
  A,
478
- B
479
- ][number] extends true ? true : true extends [
480
- IsEqual<A, false>,
481
- IsEqual<B, false>
482
- ][number] ? false : never;
512
+ B,
513
+ ][number] extends true
514
+ ? true
515
+ : true extends [IsEqual<A, false>, IsEqual<B, false>][number]
516
+ ? false
517
+ : never;
483
518
  /**
484
519
  Returns a boolean for whether either of two given types are true.
485
520
 
@@ -500,11 +535,12 @@ Or<false, false>;
500
535
  */
501
536
  export type Or<A extends boolean, B extends boolean> = [
502
537
  A,
503
- B
504
- ][number] extends false ? false : true extends [
505
- IsEqual<A, true>,
506
- IsEqual<B, true>
507
- ][number] ? true : never;
538
+ B,
539
+ ][number] extends false
540
+ ? false
541
+ : true extends [IsEqual<A, true>, IsEqual<B, true>][number]
542
+ ? true
543
+ : never;
508
544
  /**
509
545
  Returns a boolean for whether a given number is greater than another number.
510
546
 
@@ -522,32 +558,44 @@ GreaterThan<1, 5>;
522
558
  //=> false
523
559
  ```
524
560
  */
525
- export type GreaterThan<A extends number, B extends number> = number extends A | B ? never : [
526
- IsEqual<A, PositiveInfinity>,
527
- IsEqual<A, NegativeInfinity>,
528
- IsEqual<B, PositiveInfinity>,
529
- IsEqual<B, NegativeInfinity>
530
- ] extends infer R extends [
531
- boolean,
532
- boolean,
533
- boolean,
534
- boolean
535
- ] ? Or<And<IsEqual<R[0], true>, IsEqual<R[2], false>>, And<IsEqual<R[3], true>, IsEqual<R[1], false>>> extends true ? true : Or<And<IsEqual<R[1], true>, IsEqual<R[3], false>>, And<IsEqual<R[2], true>, IsEqual<R[0], false>>> extends true ? false : true extends R[number] ? false : [
536
- IsNegative<A>,
537
- IsNegative<B>
538
- ] extends infer R extends [
539
- boolean,
540
- boolean
541
- ] ? [
542
- true,
543
- false
544
- ] extends R ? false : [
545
- false,
546
- true
547
- ] extends R ? true : [
548
- false,
549
- false
550
- ] extends R ? PositiveNumericStringGt<`${A}`, `${B}`> : PositiveNumericStringGt<`${NumberAbsolute<B>}`, `${NumberAbsolute<A>}`> : never : never;
561
+ export type GreaterThan<A extends number, B extends number> = number extends
562
+ | A
563
+ | B
564
+ ? never
565
+ : [
566
+ IsEqual<A, PositiveInfinity>,
567
+ IsEqual<A, NegativeInfinity>,
568
+ IsEqual<B, PositiveInfinity>,
569
+ IsEqual<B, NegativeInfinity>,
570
+ ] extends infer R extends [boolean, boolean, boolean, boolean]
571
+ ? Or<
572
+ And<IsEqual<R[0], true>, IsEqual<R[2], false>>,
573
+ And<IsEqual<R[3], true>, IsEqual<R[1], false>>
574
+ > extends true
575
+ ? true
576
+ : Or<
577
+ And<IsEqual<R[1], true>, IsEqual<R[3], false>>,
578
+ And<IsEqual<R[2], true>, IsEqual<R[0], false>>
579
+ > extends true
580
+ ? false
581
+ : true extends R[number]
582
+ ? false
583
+ : [IsNegative<A>, IsNegative<B>] extends infer R extends [
584
+ boolean,
585
+ boolean,
586
+ ]
587
+ ? [true, false] extends R
588
+ ? false
589
+ : [false, true] extends R
590
+ ? true
591
+ : [false, false] extends R
592
+ ? PositiveNumericStringGt<`${A}`, `${B}`>
593
+ : PositiveNumericStringGt<
594
+ `${NumberAbsolute<B>}`,
595
+ `${NumberAbsolute<A>}`
596
+ >
597
+ : never
598
+ : never;
551
599
  /**
552
600
  Returns a boolean for whether a given number is greater than or equal to another number.
553
601
 
@@ -565,7 +613,10 @@ GreaterThanOrEqual<1, 5>;
565
613
  //=> false
566
614
  ```
567
615
  */
568
- export type GreaterThanOrEqual<A extends number, B extends number> = number extends A | B ? never : A extends B ? true : GreaterThan<A, B>;
616
+ export type GreaterThanOrEqual<
617
+ A extends number,
618
+ B extends number,
619
+ > = number extends A | B ? never : A extends B ? true : GreaterThan<A, B>;
569
620
  /**
570
621
  Returns a boolean for whether a given number is less than another number.
571
622
 
@@ -583,7 +634,11 @@ LessThan<1, 5>;
583
634
  //=> true
584
635
  ```
585
636
  */
586
- export type LessThan<A extends number, B extends number> = number extends A | B ? never : GreaterThanOrEqual<A, B> extends true ? false : true;
637
+ export type LessThan<A extends number, B extends number> = number extends A | B
638
+ ? never
639
+ : GreaterThanOrEqual<A, B> extends true
640
+ ? false
641
+ : true;
587
642
  /**
588
643
  Create a tuple type of the given length `<L>` and fill it with the given type `<Fill>`.
589
644
 
@@ -591,11 +646,11 @@ If `<Fill>` is not provided, it will default to `unknown`.
591
646
 
592
647
  @link https://itnext.io/implementing-arithmetic-within-typescripts-type-system-a1ef140a6f6f
593
648
  */
594
- export type BuildTuple<L extends number, Fill = unknown, T extends readonly unknown[] = [
595
- ]> = T["length"] extends L ? T : BuildTuple<L, Fill, [
596
- ...T,
597
- Fill
598
- ]>;
649
+ export type BuildTuple<
650
+ L extends number,
651
+ Fill = unknown,
652
+ T extends readonly unknown[] = [],
653
+ > = T['length'] extends L ? T : BuildTuple<L, Fill, [...T, Fill]>;
599
654
  /**
600
655
  Returns the maximum value from a tuple of integers.
601
656
 
@@ -611,10 +666,16 @@ ArrayMax<[1, 2, 5, 3, 99, -1]>;
611
666
  //=> 99
612
667
  ```
613
668
  */
614
- export type TupleMax<A extends number[], Result extends number = NegativeInfinity> = number extends A[number] ? never : A extends [
615
- infer F extends number,
616
- ...infer R extends number[]
617
- ] ? GreaterThan<F, Result> extends true ? TupleMax<R, F> : TupleMax<R, Result> : Result;
669
+ export type TupleMax<
670
+ A extends number[],
671
+ Result extends number = NegativeInfinity,
672
+ > = number extends A[number]
673
+ ? never
674
+ : A extends [infer F extends number, ...infer R extends number[]]
675
+ ? GreaterThan<F, Result> extends true
676
+ ? TupleMax<R, F>
677
+ : TupleMax<R, Result>
678
+ : Result;
618
679
  /**
619
680
  Returns the minimum value from a tuple of integers.
620
681
 
@@ -630,10 +691,16 @@ ArrayMin<[1, 2, 5, 3, -5]>;
630
691
  //=> -5
631
692
  ```
632
693
  */
633
- export type TupleMin<A extends number[], Result extends number = PositiveInfinity> = number extends A[number] ? never : A extends [
634
- infer F extends number,
635
- ...infer R extends number[]
636
- ] ? LessThan<F, Result> extends true ? TupleMin<R, F> : TupleMin<R, Result> : Result;
694
+ export type TupleMin<
695
+ A extends number[],
696
+ Result extends number = PositiveInfinity,
697
+ > = number extends A[number]
698
+ ? never
699
+ : A extends [infer F extends number, ...infer R extends number[]]
700
+ ? LessThan<F, Result> extends true
701
+ ? TupleMin<R, F>
702
+ : TupleMin<R, Result>
703
+ : Result;
637
704
  /**
638
705
  Return a string representation of the given string or number.
639
706
 
@@ -668,7 +735,14 @@ type NegativeInfinity = StringToNumber<'-Infinity'>;
668
735
  @category Numeric
669
736
  @category Template literal
670
737
  */
671
- export type StringToNumber<S extends string> = S extends `${infer N extends number}` ? N : S extends "Infinity" ? PositiveInfinity : S extends "-Infinity" ? NegativeInfinity : never;
738
+ export type StringToNumber<S extends string> =
739
+ S extends `${infer N extends number}`
740
+ ? N
741
+ : S extends 'Infinity'
742
+ ? PositiveInfinity
743
+ : S extends '-Infinity'
744
+ ? NegativeInfinity
745
+ : never;
672
746
  /**
673
747
  Returns an array of the characters of the string.
674
748
 
@@ -683,11 +757,14 @@ StringToArray<string>;
683
757
 
684
758
  @category String
685
759
  */
686
- export type StringToArray<S extends string, Result extends string[] = [
687
- ]> = string extends S ? never : S extends `${infer F}${infer R}` ? StringToArray<R, [
688
- ...Result,
689
- F
690
- ]> : Result;
760
+ export type StringToArray<
761
+ S extends string,
762
+ Result extends string[] = [],
763
+ > = string extends S
764
+ ? never
765
+ : S extends `${infer F}${infer R}`
766
+ ? StringToArray<R, [...Result, F]>
767
+ : Result;
691
768
  /**
692
769
  Returns the length of the given string.
693
770
 
@@ -703,7 +780,9 @@ StringLength<string>;
703
780
  @category String
704
781
  @category Template literal
705
782
  */
706
- export type StringLength<S extends string> = string extends S ? never : StringToArray<S>["length"];
783
+ export type StringLength<S extends string> = string extends S
784
+ ? never
785
+ : StringToArray<S>['length'];
707
786
  /**
708
787
  Returns a boolean for whether `A` represents a number greater than `B`, where `A` and `B` are both numeric strings and have the same length.
709
788
 
@@ -716,8 +795,17 @@ SameLengthPositiveNumericStringGt<'10', '10'>;
716
795
  //=> false
717
796
  ```
718
797
  */
719
- export type SameLengthPositiveNumericStringGt<A extends string, B extends string> = A extends `${infer FirstA}${infer RestA}` ? B extends `${infer FirstB}${infer RestB}` ? FirstA extends FirstB ? SameLengthPositiveNumericStringGt<RestA, RestB> : PositiveNumericCharacterGt<FirstA, FirstB> : never : false;
720
- export type NumericString = "0123456789";
798
+ export type SameLengthPositiveNumericStringGt<
799
+ A extends string,
800
+ B extends string,
801
+ > = A extends `${infer FirstA}${infer RestA}`
802
+ ? B extends `${infer FirstB}${infer RestB}`
803
+ ? FirstA extends FirstB
804
+ ? SameLengthPositiveNumericStringGt<RestA, RestB>
805
+ : PositiveNumericCharacterGt<FirstA, FirstB>
806
+ : never
807
+ : false;
808
+ export type NumericString = '0123456789';
721
809
  /**
722
810
  Returns a boolean for whether `A` is greater than `B`, where `A` and `B` are both positive numeric strings.
723
811
 
@@ -733,16 +821,21 @@ PositiveNumericStringGt<'1', '500'>;
733
821
  //=> false
734
822
  ```
735
823
  */
736
- export type PositiveNumericStringGt<A extends string, B extends string> = A extends B ? false : [
737
- BuildTuple<StringLength<A>, 0>,
738
- BuildTuple<StringLength<B>, 0>
739
- ] extends infer R extends [
740
- readonly unknown[],
741
- readonly unknown[]
742
- ] ? R[0] extends [
743
- ...R[1],
744
- ...infer Remain extends readonly unknown[]
745
- ] ? 0 extends Remain["length"] ? SameLengthPositiveNumericStringGt<A, B> : true : false : never;
824
+ export type PositiveNumericStringGt<
825
+ A extends string,
826
+ B extends string,
827
+ > = A extends B
828
+ ? false
829
+ : [
830
+ BuildTuple<StringLength<A>, 0>,
831
+ BuildTuple<StringLength<B>, 0>,
832
+ ] extends infer R extends [readonly unknown[], readonly unknown[]]
833
+ ? R[0] extends [...R[1], ...infer Remain extends readonly unknown[]]
834
+ ? 0 extends Remain['length']
835
+ ? SameLengthPositiveNumericStringGt<A, B>
836
+ : true
837
+ : false
838
+ : never;
746
839
  /**
747
840
  Returns a boolean for whether `A` represents a number greater than `B`, where `A` and `B` are both positive numeric characters.
748
841
 
@@ -755,7 +848,16 @@ PositiveNumericCharacterGt<'1', '1'>;
755
848
  //=> false
756
849
  ```
757
850
  */
758
- export type PositiveNumericCharacterGt<A extends string, B extends string> = NumericString extends `${infer HeadA}${A}${infer TailA}` ? NumericString extends `${infer HeadB}${B}${infer TailB}` ? HeadA extends `${HeadB}${infer _}${infer __}` ? true : false : never : never;
851
+ export type PositiveNumericCharacterGt<
852
+ A extends string,
853
+ B extends string,
854
+ > = NumericString extends `${infer HeadA}${A}${infer TailA}`
855
+ ? NumericString extends `${infer HeadB}${B}${infer TailB}`
856
+ ? HeadA extends `${HeadB}${infer _}${infer __}`
857
+ ? true
858
+ : false
859
+ : never
860
+ : never;
759
861
  /**
760
862
  Returns the absolute value of a given value.
761
863
 
@@ -771,7 +873,10 @@ NumberAbsolute<NegativeInfinity>
771
873
  //=> PositiveInfinity
772
874
  ```
773
875
  */
774
- export type NumberAbsolute<N extends number> = `${N}` extends `-${infer StringPositiveN}` ? StringToNumber<StringPositiveN> : N;
876
+ export type NumberAbsolute<N extends number> =
877
+ `${N}` extends `-${infer StringPositiveN}`
878
+ ? StringToNumber<StringPositiveN>
879
+ : N;
775
880
  /**
776
881
  Check whether the given type is a number or a number string.
777
882
 
@@ -791,7 +896,13 @@ type C = IsNumberLike<1>;
791
896
  type D = IsNumberLike<'a'>;
792
897
  //=> false
793
898
  */
794
- export type IsNumberLike<N> = N extends number ? true : N extends `${number}` ? true : N extends `${number}.${number}` ? true : false;
899
+ export type IsNumberLike<N> = N extends number
900
+ ? true
901
+ : N extends `${number}`
902
+ ? true
903
+ : N extends `${number}.${number}`
904
+ ? true
905
+ : false;
795
906
  /**
796
907
  Matches any primitive, `void`, `Date`, or `RegExp` value.
797
908
  */
@@ -799,7 +910,12 @@ export type BuiltIns = Primitive | void | Date | RegExp;
799
910
  /**
800
911
  Matches non-recursive types.
801
912
  */
802
- export type NonRecursiveType = BuiltIns | Function | (new (...arguments_: any[]) => unknown);
913
+ export type NonRecursiveType =
914
+ | BuiltIns
915
+ | Function
916
+ | (new (
917
+ ...arguments_: any[]
918
+ ) => unknown);
803
919
  /**
804
920
  Returns the sum of two numbers.
805
921
 
@@ -831,35 +947,45 @@ Sum<PositiveInfinity, NegativeInfinity>;
831
947
  @category Numeric
832
948
  */
833
949
  // TODO: Support big integer and negative number.
834
- export type Sum<A extends number, B extends number> = number extends A | B ? number : [
835
- IsEqual<A, PositiveInfinity>,
836
- IsEqual<A, NegativeInfinity>,
837
- IsEqual<B, PositiveInfinity>,
838
- IsEqual<B, NegativeInfinity>
839
- ] extends infer R extends [
840
- boolean,
841
- boolean,
842
- boolean,
843
- boolean
844
- ] ? Or<And<IsEqual<R[0], true>, IsEqual<R[3], false>>, And<IsEqual<R[2], true>, IsEqual<R[1], false>>> extends true ? PositiveInfinity : Or<And<IsEqual<R[1], true>, IsEqual<R[2], false>>, And<IsEqual<R[3], true>, IsEqual<R[0], false>>> extends true ? NegativeInfinity : true extends R[number] ? number : ([
845
- IsNegative<A>,
846
- IsNegative<B>
847
- ] extends infer R ? [
848
- false,
849
- false
850
- ] extends R ? [
851
- ...BuildTuple<A>,
852
- ...BuildTuple<B>
853
- ]["length"] : [
854
- true,
855
- true
856
- ] extends R ? number : TupleMax<[
857
- NumberAbsolute<A>,
858
- NumberAbsolute<B>
859
- ]> extends infer Max_ ? TupleMin<[
860
- NumberAbsolute<A>,
861
- NumberAbsolute<B>
862
- ]> extends infer Min_ extends number ? Max_ extends A | B ? Subtract<Max_, Min_> : number : never : never : never) & number : never;
950
+ export type Sum<A extends number, B extends number> = number extends A | B
951
+ ? number
952
+ : [
953
+ IsEqual<A, PositiveInfinity>,
954
+ IsEqual<A, NegativeInfinity>,
955
+ IsEqual<B, PositiveInfinity>,
956
+ IsEqual<B, NegativeInfinity>,
957
+ ] extends infer R extends [boolean, boolean, boolean, boolean]
958
+ ? Or<
959
+ And<IsEqual<R[0], true>, IsEqual<R[3], false>>,
960
+ And<IsEqual<R[2], true>, IsEqual<R[1], false>>
961
+ > extends true
962
+ ? PositiveInfinity
963
+ : Or<
964
+ And<IsEqual<R[1], true>, IsEqual<R[2], false>>,
965
+ And<IsEqual<R[3], true>, IsEqual<R[0], false>>
966
+ > extends true
967
+ ? NegativeInfinity
968
+ : true extends R[number]
969
+ ? number
970
+ : ([IsNegative<A>, IsNegative<B>] extends infer R
971
+ ? [false, false] extends R
972
+ ? [...BuildTuple<A>, ...BuildTuple<B>]['length']
973
+ : [true, true] extends R
974
+ ? number
975
+ : TupleMax<
976
+ [NumberAbsolute<A>, NumberAbsolute<B>]
977
+ > extends infer Max_
978
+ ? TupleMin<
979
+ [NumberAbsolute<A>, NumberAbsolute<B>]
980
+ > extends infer Min_ extends number
981
+ ? Max_ extends A | B
982
+ ? Subtract<Max_, Min_>
983
+ : number
984
+ : never
985
+ : never
986
+ : never) &
987
+ number
988
+ : never;
863
989
  /**
864
990
  Returns the difference between two numbers.
865
991
 
@@ -890,29 +1016,40 @@ Subtract<PositiveInfinity, PositiveInfinity>;
890
1016
  @category Numeric
891
1017
  */
892
1018
  // TODO: Support big integer and negative number.
893
- export type Subtract<A extends number, B extends number> = number extends A | B ? number : [
894
- IsEqual<A, PositiveInfinity>,
895
- IsEqual<A, NegativeInfinity>,
896
- IsEqual<B, PositiveInfinity>,
897
- IsEqual<B, NegativeInfinity>
898
- ] extends infer R extends [
899
- boolean,
900
- boolean,
901
- boolean,
902
- boolean
903
- ] ? Or<And<IsEqual<R[0], true>, IsEqual<R[2], false>>, And<IsEqual<R[3], true>, IsEqual<R[1], false>>> extends true ? PositiveInfinity : Or<And<IsEqual<R[1], true>, IsEqual<R[3], false>>, And<IsEqual<R[2], true>, IsEqual<R[0], false>>> extends true ? NegativeInfinity : true extends R[number] ? number : [
904
- IsNegative<A>,
905
- IsNegative<B>
906
- ] extends infer R ? [
907
- false,
908
- false
909
- ] extends R ? BuildTuple<A> extends infer R ? R extends [
910
- ...BuildTuple<B>,
911
- ...infer R
912
- ] ? R["length"] : number : never : LessThan<A, B> extends true ? number : [
913
- false,
914
- true
915
- ] extends R ? Sum<A, NumberAbsolute<B>> : Subtract<NumberAbsolute<B>, NumberAbsolute<A>> : never : never;
1019
+ export type Subtract<A extends number, B extends number> = number extends A | B
1020
+ ? number
1021
+ : [
1022
+ IsEqual<A, PositiveInfinity>,
1023
+ IsEqual<A, NegativeInfinity>,
1024
+ IsEqual<B, PositiveInfinity>,
1025
+ IsEqual<B, NegativeInfinity>,
1026
+ ] extends infer R extends [boolean, boolean, boolean, boolean]
1027
+ ? Or<
1028
+ And<IsEqual<R[0], true>, IsEqual<R[2], false>>,
1029
+ And<IsEqual<R[3], true>, IsEqual<R[1], false>>
1030
+ > extends true
1031
+ ? PositiveInfinity
1032
+ : Or<
1033
+ And<IsEqual<R[1], true>, IsEqual<R[3], false>>,
1034
+ And<IsEqual<R[2], true>, IsEqual<R[0], false>>
1035
+ > extends true
1036
+ ? NegativeInfinity
1037
+ : true extends R[number]
1038
+ ? number
1039
+ : [IsNegative<A>, IsNegative<B>] extends infer R
1040
+ ? [false, false] extends R
1041
+ ? BuildTuple<A> extends infer R
1042
+ ? R extends [...BuildTuple<B>, ...infer R]
1043
+ ? R['length']
1044
+ : number
1045
+ : never
1046
+ : LessThan<A, B> extends true
1047
+ ? number
1048
+ : [false, true] extends R
1049
+ ? Sum<A, NumberAbsolute<B>>
1050
+ : Subtract<NumberAbsolute<B>, NumberAbsolute<A>>
1051
+ : never
1052
+ : never;
916
1053
  /**
917
1054
  Paths options.
918
1055
 
@@ -1003,28 +1140,85 @@ open('listB.1'); // TypeError. Because listB only has one element.
1003
1140
  @category Object
1004
1141
  @category Array
1005
1142
  */
1006
- export type Paths<T, Options extends PathsOptions = {}> = _Paths<T, {
1007
- // Set default maxRecursionDepth to 10
1008
- maxRecursionDepth: Options["maxRecursionDepth"] extends number ? Options["maxRecursionDepth"] : DefaultPathsOptions["maxRecursionDepth"];
1009
- // Set default bracketNotation to false
1010
- bracketNotation: Options["bracketNotation"] extends boolean ? Options["bracketNotation"] : DefaultPathsOptions["bracketNotation"];
1011
- }>;
1012
- export type _Paths<T, Options extends Required<PathsOptions>> = T extends NonRecursiveType | ReadonlyMap<unknown, unknown> | ReadonlySet<unknown> ? never : IsAny<T> extends true ? never : T extends UnknownArray ? number extends T["length"] ? InternalPaths<StaticPartOfArray<T>, Options> | InternalPaths<Array<VariablePartOfArray<T>[number]>, Options> : InternalPaths<T, Options> : T extends object ? InternalPaths<T, Options> : never;
1013
- export type InternalPaths<T, Options extends Required<PathsOptions>> = Options["maxRecursionDepth"] extends infer MaxDepth extends number ? Required<T> extends infer T ? T extends EmptyObject | readonly [
1014
- ] ? never : {
1015
- [Key in keyof T]: Key extends string | number // Limit `Key` to string or number.
1016
- ? (Options["bracketNotation"] extends true ? IsNumberLike<Key> extends true ? `[${Key}]` : (Key | ToString<Key>) : never | Options["bracketNotation"] extends false ? (Key | ToString<Key>) : never) extends infer TranformedKey extends string | number ?
1017
- // 1. If style is 'a[0].b' and 'Key' is a numberlike value like 3 or '3', transform 'Key' to `[${Key}]`, else to `${Key}` | Key
1018
- // 2. If style is 'a.0.b', transform 'Key' to `${Key}` | Key
1019
- TranformedKey | (
1020
- // Recursively generate paths for the current key
1021
- GreaterThan<MaxDepth, 0> extends true // Limit the depth to prevent infinite recursion
1022
- ? _Paths<T[Key], {
1023
- bracketNotation: Options["bracketNotation"];
1024
- maxRecursionDepth: Subtract<MaxDepth, 1>;
1025
- }> extends infer SubPath ? SubPath extends string | number ? (Options["bracketNotation"] extends true ? SubPath extends `[${any}]` | `[${any}]${string}` ? `${TranformedKey}${SubPath}` // If next node is number key like `[3]`, no need to add `.` before it.
1026
- : `${TranformedKey}.${SubPath}` : never) | (Options["bracketNotation"] extends false ? `${TranformedKey}.${SubPath}` : never) : never : never : never) : never : never;
1027
- }[keyof T & (T extends UnknownArray ? number : unknown)] : never : never;
1143
+ export type Paths<T, Options extends PathsOptions = {}> = _Paths<
1144
+ T,
1145
+ {
1146
+ // Set default maxRecursionDepth to 10
1147
+ maxRecursionDepth: Options['maxRecursionDepth'] extends number
1148
+ ? Options['maxRecursionDepth']
1149
+ : DefaultPathsOptions['maxRecursionDepth'];
1150
+ // Set default bracketNotation to false
1151
+ bracketNotation: Options['bracketNotation'] extends boolean
1152
+ ? Options['bracketNotation']
1153
+ : DefaultPathsOptions['bracketNotation'];
1154
+ }
1155
+ >;
1156
+ export type _Paths<T, Options extends Required<PathsOptions>> = T extends
1157
+ | NonRecursiveType
1158
+ | ReadonlyMap<unknown, unknown>
1159
+ | ReadonlySet<unknown>
1160
+ ? never
1161
+ : IsAny<T> extends true
1162
+ ? never
1163
+ : T extends UnknownArray
1164
+ ? number extends T['length']
1165
+ ?
1166
+ | InternalPaths<StaticPartOfArray<T>, Options>
1167
+ | InternalPaths<Array<VariablePartOfArray<T>[number]>, Options>
1168
+ : InternalPaths<T, Options>
1169
+ : T extends object
1170
+ ? InternalPaths<T, Options>
1171
+ : never;
1172
+ export type InternalPaths<
1173
+ T,
1174
+ Options extends Required<PathsOptions>,
1175
+ > = Options['maxRecursionDepth'] extends infer MaxDepth extends number
1176
+ ? Required<T> extends infer T
1177
+ ? T extends EmptyObject | readonly []
1178
+ ? never
1179
+ : {
1180
+ [Key in keyof T]: Key extends string | number // Limit `Key` to string or number.
1181
+ ? (
1182
+ Options['bracketNotation'] extends true
1183
+ ? IsNumberLike<Key> extends true
1184
+ ? `[${Key}]`
1185
+ : Key | ToString<Key>
1186
+ : never | Options['bracketNotation'] extends false
1187
+ ? Key | ToString<Key>
1188
+ : never
1189
+ ) extends infer TranformedKey extends string | number
1190
+ ? // 1. If style is 'a[0].b' and 'Key' is a numberlike value like 3 or '3', transform 'Key' to `[${Key}]`, else to `${Key}` | Key
1191
+ // 2. If style is 'a.0.b', transform 'Key' to `${Key}` | Key
1192
+ | TranformedKey
1193
+ // Recursively generate paths for the current key
1194
+ | (GreaterThan<MaxDepth, 0> extends true // Limit the depth to prevent infinite recursion
1195
+ ? _Paths<
1196
+ T[Key],
1197
+ {
1198
+ bracketNotation: Options['bracketNotation'];
1199
+ maxRecursionDepth: Subtract<MaxDepth, 1>;
1200
+ }
1201
+ > extends infer SubPath
1202
+ ? SubPath extends string | number
1203
+ ?
1204
+ | (Options['bracketNotation'] extends true
1205
+ ? SubPath extends
1206
+ | `[${any}]`
1207
+ | `[${any}]${string}`
1208
+ ? `${TranformedKey}${SubPath}` // If next node is number key like `[3]`, no need to add `.` before it.
1209
+ : `${TranformedKey}.${SubPath}`
1210
+ : never)
1211
+ | (Options['bracketNotation'] extends false
1212
+ ? `${TranformedKey}.${SubPath}`
1213
+ : never)
1214
+ : never
1215
+ : never
1216
+ : never)
1217
+ : never
1218
+ : never;
1219
+ }[keyof T & (T extends UnknownArray ? number : unknown)]
1220
+ : never
1221
+ : never;
1028
1222
  export type LiteralStringUnion<T> = LiteralUnion<T, string>;
1029
1223
  /**
1030
1224
  Allows creating a union type by combining primitive types and literal types without sacrificing auto-completion in IDEs for the literal type part of the union.
@@ -1055,7 +1249,9 @@ const pet: Pet2 = '';
1055
1249
 
1056
1250
  @category Type
1057
1251
  */
1058
- export type LiteralUnion<LiteralType, BaseType extends Primitive> = LiteralType | (BaseType & Record<never, never>);
1252
+ export type LiteralUnion<LiteralType, BaseType extends Primitive> =
1253
+ | LiteralType
1254
+ | (BaseType & Record<never, never>);
1059
1255
  /**
1060
1256
  Get keys of the given type as strings.
1061
1257
 
@@ -1080,7 +1276,8 @@ type StringKeysOfFoo = StringKeyOf<Foo>;
1080
1276
 
1081
1277
  @category Object
1082
1278
  */
1083
- export type StringKeyOf<BaseType> = `${Extract<keyof BaseType, string | number>}`;
1279
+ export type StringKeyOf<BaseType> =
1280
+ `${Extract<keyof BaseType, string | number>}`;
1084
1281
  /**
1085
1282
  Represents an array of strings split using a given character or character set.
1086
1283
 
@@ -1102,13 +1299,14 @@ array = split(items, ',');
1102
1299
  @category String
1103
1300
  @category Template literal
1104
1301
  */
1105
- export type Split<S extends string, Delimiter extends string> = S extends `${infer Head}${Delimiter}${infer Tail}` ? [
1106
- Head,
1107
- ...Split<Tail, Delimiter>
1108
- ] : S extends Delimiter ? [
1109
- ] : [
1110
- S
1111
- ];
1302
+ export type Split<
1303
+ S extends string,
1304
+ Delimiter extends string,
1305
+ > = S extends `${infer Head}${Delimiter}${infer Tail}`
1306
+ ? [Head, ...Split<Tail, Delimiter>]
1307
+ : S extends Delimiter
1308
+ ? []
1309
+ : [S];
1112
1310
  export type GetOptions = {
1113
1311
  /**
1114
1312
  Include `undefined` in the return type when accessing properties.
@@ -1122,24 +1320,41 @@ export type GetOptions = {
1122
1320
  /**
1123
1321
  Like the `Get` type but receives an array of strings as a path parameter.
1124
1322
  */
1125
- export type GetWithPath<BaseType, Keys, Options extends GetOptions = {}> = Keys extends readonly [
1126
- ] ? BaseType : Keys extends readonly [
1127
- infer Head,
1128
- ...infer Tail
1129
- ] ? GetWithPath<PropertyOf<BaseType, Extract<Head, string>, Options>, Extract<Tail, string[]>, Options> : never;
1323
+ export type GetWithPath<
1324
+ BaseType,
1325
+ Keys,
1326
+ Options extends GetOptions = {},
1327
+ > = Keys extends readonly []
1328
+ ? BaseType
1329
+ : Keys extends readonly [infer Head, ...infer Tail]
1330
+ ? GetWithPath<
1331
+ PropertyOf<BaseType, Extract<Head, string>, Options>,
1332
+ Extract<Tail, string[]>,
1333
+ Options
1334
+ >
1335
+ : never;
1130
1336
  /**
1131
1337
  Adds `undefined` to `Type` if `strict` is enabled.
1132
1338
  */
1133
- export type Strictify<Type, Options extends GetOptions> = Options["strict"] extends false ? Type : (Type | undefined);
1339
+ export type Strictify<
1340
+ Type,
1341
+ Options extends GetOptions,
1342
+ > = Options['strict'] extends false ? Type : Type | undefined;
1134
1343
  /**
1135
1344
  If `Options['strict']` is `true`, includes `undefined` in the returned type when accessing properties on `Record<string, any>`.
1136
1345
 
1137
1346
  Known limitations:
1138
1347
  - Does not include `undefined` in the type on object types with an index signature (for example, `{a: string; [key: string]: string}`).
1139
1348
  */
1140
- export type StrictPropertyOf<BaseType, Key extends keyof BaseType, Options extends GetOptions> = Record<string, any> extends BaseType ? string extends keyof BaseType ? Strictify<BaseType[Key], Options> // Record<string, any>
1141
- : BaseType[Key] // Record<'a' | 'b', any> (Records with a string union as keys have required properties)
1142
- : BaseType[Key];
1349
+ export type StrictPropertyOf<
1350
+ BaseType,
1351
+ Key extends keyof BaseType,
1352
+ Options extends GetOptions,
1353
+ > = Record<string, any> extends BaseType
1354
+ ? string extends keyof BaseType
1355
+ ? Strictify<BaseType[Key], Options> // Record<string, any>
1356
+ : BaseType[Key] // Record<'a' | 'b', any> (Records with a string union as keys have required properties)
1357
+ : BaseType[Key];
1143
1358
  /**
1144
1359
  Splits a dot-prop style path into a tuple comprised of the properties in the path. Handles square-bracket notation.
1145
1360
 
@@ -1152,11 +1367,18 @@ ToPath<'foo[0].bar.baz'>
1152
1367
  //=> ['foo', '0', 'bar', 'baz']
1153
1368
  ```
1154
1369
  */
1155
- export type ToPath<S extends string> = Split<FixPathSquareBrackets<S>, ".">;
1370
+ export type ToPath<S extends string> = Split<FixPathSquareBrackets<S>, '.'>;
1156
1371
  /**
1157
1372
  Replaces square-bracketed dot notation with dots, for example, `foo[0].bar` -> `foo.0.bar`.
1158
1373
  */
1159
- export type FixPathSquareBrackets<Path extends string> = Path extends `[${infer Head}]${infer Tail}` ? Tail extends `[${string}` ? `${Head}.${FixPathSquareBrackets<Tail>}` : `${Head}${FixPathSquareBrackets<Tail>}` : Path extends `${infer Head}[${infer Middle}]${infer Tail}` ? `${Head}.${FixPathSquareBrackets<`[${Middle}]${Tail}`>}` : Path;
1374
+ export type FixPathSquareBrackets<Path extends string> =
1375
+ Path extends `[${infer Head}]${infer Tail}`
1376
+ ? Tail extends `[${string}`
1377
+ ? `${Head}.${FixPathSquareBrackets<Tail>}`
1378
+ : `${Head}${FixPathSquareBrackets<Tail>}`
1379
+ : Path extends `${infer Head}[${infer Middle}]${infer Tail}`
1380
+ ? `${Head}.${FixPathSquareBrackets<`[${Middle}]${Tail}`>}`
1381
+ : Path;
1160
1382
  /**
1161
1383
  Returns true if `LongString` is made up out of `Substring` repeated 0 or more times.
1162
1384
 
@@ -1168,7 +1390,14 @@ ConsistsOnlyOf<'aBa', 'a'> //=> false
1168
1390
  ConsistsOnlyOf<'', 'a'> //=> true
1169
1391
  ```
1170
1392
  */
1171
- export type ConsistsOnlyOf<LongString extends string, Substring extends string> = LongString extends "" ? true : LongString extends `${Substring}${infer Tail}` ? ConsistsOnlyOf<Tail, Substring> : false;
1393
+ export type ConsistsOnlyOf<
1394
+ LongString extends string,
1395
+ Substring extends string,
1396
+ > = LongString extends ''
1397
+ ? true
1398
+ : LongString extends `${Substring}${infer Tail}`
1399
+ ? ConsistsOnlyOf<Tail, Substring>
1400
+ : false;
1172
1401
  /**
1173
1402
  Convert a type which may have number keys to one with string keys, making it possible to index using strings retrieved from template types.
1174
1403
 
@@ -1189,11 +1418,11 @@ export type WithStringKeys<BaseType> = {
1189
1418
  /**
1190
1419
  Perform a `T[U]` operation if `T` supports indexing.
1191
1420
  */
1192
- export type UncheckedIndex<T, U extends string | number> = [
1193
- T
1194
- ] extends [
1195
- Record<string | number, any>
1196
- ] ? T[U] : never;
1421
+ export type UncheckedIndex<T, U extends string | number> = [T] extends [
1422
+ Record<string | number, any>,
1423
+ ]
1424
+ ? T[U]
1425
+ : never;
1197
1426
  /**
1198
1427
  Get a property of an object or array. Works when indexing arrays using number-literal-strings, for example, `PropertyOf<number[], '0'> = number`, and when indexing objects with number keys.
1199
1428
 
@@ -1201,15 +1430,26 @@ Note:
1201
1430
  - Returns `unknown` if `Key` is not a property of `BaseType`, since TypeScript uses structural typing, and it cannot be guaranteed that extra properties unknown to the type system will exist at runtime.
1202
1431
  - Returns `undefined` from nullish values, to match the behaviour of most deep-key libraries like `lodash`, `dot-prop`, etc.
1203
1432
  */
1204
- export type PropertyOf<BaseType, Key extends string, Options extends GetOptions = {}> = BaseType extends null | undefined ? undefined : Key extends keyof BaseType ? StrictPropertyOf<BaseType, Key, Options> : BaseType extends readonly [
1205
- ] | readonly [
1206
- unknown,
1207
- ...unknown[]
1208
- ] ? unknown // It's a tuple, but `Key` did not extend `keyof BaseType`. So the index is out of bounds.
1209
- : BaseType extends {
1210
- [n: number]: infer Item;
1211
- length: number; // Note: This is needed to avoid being too lax with records types using number keys like `{0: string; 1: boolean}`.
1212
- } ? (ConsistsOnlyOf<Key, StringDigit> extends true ? Strictify<Item, Options> : unknown) : Key extends keyof WithStringKeys<BaseType> ? StrictPropertyOf<WithStringKeys<BaseType>, Key, Options> : unknown;
1433
+ export type PropertyOf<
1434
+ BaseType,
1435
+ Key extends string,
1436
+ Options extends GetOptions = {},
1437
+ > = BaseType extends null | undefined
1438
+ ? undefined
1439
+ : Key extends keyof BaseType
1440
+ ? StrictPropertyOf<BaseType, Key, Options>
1441
+ : BaseType extends readonly [] | readonly [unknown, ...unknown[]]
1442
+ ? unknown // It's a tuple, but `Key` did not extend `keyof BaseType`. So the index is out of bounds.
1443
+ : BaseType extends {
1444
+ [n: number]: infer Item;
1445
+ length: number; // Note: This is needed to avoid being too lax with records types using number keys like `{0: string; 1: boolean}`.
1446
+ }
1447
+ ? ConsistsOnlyOf<Key, StringDigit> extends true
1448
+ ? Strictify<Item, Options>
1449
+ : unknown
1450
+ : Key extends keyof WithStringKeys<BaseType>
1451
+ ? StrictPropertyOf<WithStringKeys<BaseType>, Key, Options>
1452
+ : unknown;
1213
1453
  // This works by first splitting the path based on `.` and `[...]` characters into a tuple of string keys. Then it recursively uses the head key to get the next property of the current object, until there are no keys left. Number keys extract the item type from arrays, or are converted to strings to extract types from tuples and dictionaries with number keys.
1214
1454
  /**
1215
1455
  Get a deeply-nested property from an object using a key path, like Lodash's `.get()` function.
@@ -1257,18 +1497,40 @@ Get<Record<string, string>, 'foo', {strict: true}> // => string
1257
1497
  @category Array
1258
1498
  @category Template literal
1259
1499
  */
1260
- export type Get<BaseType, Path extends readonly string[] | LiteralStringUnion<ToString<Paths<BaseType, {
1261
- bracketNotation: false;
1262
- }> | Paths<BaseType, {
1263
- bracketNotation: true;
1264
- }>>>, Options extends GetOptions = {}> = GetWithPath<BaseType, Path extends string ? ToPath<Path> : Path, Options>;
1500
+ export type Get<
1501
+ BaseType,
1502
+ Path extends
1503
+ | readonly string[]
1504
+ | LiteralStringUnion<
1505
+ ToString<
1506
+ | Paths<
1507
+ BaseType,
1508
+ {
1509
+ bracketNotation: false;
1510
+ }
1511
+ >
1512
+ | Paths<
1513
+ BaseType,
1514
+ {
1515
+ bracketNotation: true;
1516
+ }
1517
+ >
1518
+ >
1519
+ >,
1520
+ Options extends GetOptions = {},
1521
+ > = GetWithPath<BaseType, Path extends string ? ToPath<Path> : Path, Options>;
1265
1522
  export type ArrayOrPlainObject = UnknownArray | UnknownRecord;
1266
1523
  export type EventPosition = {
1267
1524
  x: number;
1268
1525
  y: number;
1269
1526
  };
1270
- export type KeyedValue<Item, Key extends keyof Item> = Item[Key] extends PropertyKey ? Item[Key] : never;
1271
- export type NestedArrayType<Value> = Value extends Array<infer NestedValue> ? NestedArrayType<NestedValue> : Value;
1527
+ export type KeyedValue<
1528
+ Item,
1529
+ Key extends keyof Item,
1530
+ > = Item[Key] extends PropertyKey ? Item[Key] : never;
1531
+ export type NestedArrayType<Value> = Value extends Array<infer NestedValue>
1532
+ ? NestedArrayType<NestedValue>
1533
+ : Value;
1272
1534
  export type GenericCallback = (...args: any[]) => any;
1273
1535
  export type Key = number | string;
1274
1536
  export type PlainObject = UnknownRecord;
@@ -1284,12 +1546,21 @@ export declare function toQuery(parameters: PlainObject): string;
1284
1546
  /**
1285
1547
  * Is the number between a minimum and maximum value?
1286
1548
  */
1287
- export declare function between(value: number, min: number, max: number): boolean;
1549
+ export declare function between(
1550
+ value: number,
1551
+ min: number,
1552
+ max: number,
1553
+ ): boolean;
1288
1554
  /**
1289
1555
  * - Clamp a number between a minimum and maximum value
1290
1556
  * - If `loop` is `true`, when the value is less than the minimum, it will be clamped as the maximum, and vice versa
1291
1557
  */
1292
- export declare function clamp(value: number, min: number, max: number, loop?: boolean): number;
1558
+ export declare function clamp(
1559
+ value: number,
1560
+ min: number,
1561
+ max: number,
1562
+ loop?: boolean,
1563
+ ): number;
1293
1564
  /**
1294
1565
  * - Get the number value from an unknown value
1295
1566
  * - Returns `NaN` if the value is `undefined`, `null`, or cannot be parsed
@@ -1329,7 +1600,7 @@ declare class Logger {
1329
1600
  */
1330
1601
  get dir(): {
1331
1602
  (item?: any, options?: any): void;
1332
- (obj: any, options?: import("util").InspectOptions): void;
1603
+ (obj: any, options?: import('util').InspectOptions): void;
1333
1604
  };
1334
1605
  /**
1335
1606
  * Is logging to the console enabled? _(defaults to `true`)_
@@ -1405,7 +1676,9 @@ export declare const logger: Logger;
1405
1676
  /**
1406
1677
  * Is the value an array or a record?
1407
1678
  */
1408
- export declare function isArrayOrPlainObject(value: unknown): value is ArrayOrPlainObject;
1679
+ export declare function isArrayOrPlainObject(
1680
+ value: unknown,
1681
+ ): value is ArrayOrPlainObject;
1409
1682
  /**
1410
1683
  * Is the array or object completely empty or only containing `null` or `undefined` values?
1411
1684
  */
@@ -1421,11 +1694,15 @@ export declare function isNullable(value: unknown): value is undefined | null;
1421
1694
  /**
1422
1695
  * Is the value undefined, null, or an empty string?
1423
1696
  */
1424
- export declare function isNullableOrEmpty(value: unknown): value is undefined | null | "";
1697
+ export declare function isNullableOrEmpty(
1698
+ value: unknown,
1699
+ ): value is undefined | null | '';
1425
1700
  /**
1426
1701
  * Is the value undefined, null, or a whitespace-only string?
1427
1702
  */
1428
- export declare function isNullableOrWhitespace(value: unknown): value is undefined | null | "";
1703
+ export declare function isNullableOrWhitespace(
1704
+ value: unknown,
1705
+ ): value is undefined | null | '';
1429
1706
  /**
1430
1707
  * Is the value a number?
1431
1708
  */
@@ -1433,7 +1710,9 @@ export declare function isNumber(value: unknown): value is number;
1433
1710
  /**
1434
1711
  * Is the value a number, or a number-like string?
1435
1712
  */
1436
- export declare function isNumerical(value: unknown): value is number | `${number}`;
1713
+ export declare function isNumerical(
1714
+ value: unknown,
1715
+ ): value is number | `${number}`;
1437
1716
  /**
1438
1717
  * Is the value an object?
1439
1718
  */
@@ -1453,11 +1732,16 @@ export declare function chunk<Item>(array: Item[], size?: number): Item[][];
1453
1732
  /**
1454
1733
  * Compact an array _(removing all `null` and `undefined` values)_
1455
1734
  */
1456
- export declare function compact<Item>(array: Item[]): Exclude<Item, null | undefined>[];
1735
+ export declare function compact<Item>(
1736
+ array: Item[],
1737
+ ): Exclude<Item, null | undefined>[];
1457
1738
  /**
1458
1739
  * Compact an array _(removing all falsey values)_
1459
1740
  */
1460
- export declare function compact<Item>(array: Item[], strict: true): Exclude<Item, 0 | "" | false | null | undefined>[];
1741
+ export declare function compact<Item>(
1742
+ array: Item[],
1743
+ strict: true,
1744
+ ): Exclude<Item, 0 | '' | false | null | undefined>[];
1461
1745
  /**
1462
1746
  * Get the number of items _(count)_ that match the given value
1463
1747
  */
@@ -1465,15 +1749,24 @@ export declare function count<Item>(array: Item[], value: Item): number;
1465
1749
  /**
1466
1750
  * Get the number of items _(count)_ that match the given value
1467
1751
  */
1468
- export declare function count<Item>(array: Item[], matches: (item: Item, index: number, array: Item[]) => boolean): number;
1752
+ export declare function count<Item>(
1753
+ array: Item[],
1754
+ matches: (item: Item, index: number, array: Item[]) => boolean,
1755
+ ): number;
1469
1756
  /**
1470
1757
  * Get the number of items _(count)_ that match the given value
1471
1758
  */
1472
- export declare function count<Item, Key extends keyof Item>(array: Item[], key: Key, value: Item[Key]): number;
1759
+ export declare function count<
1760
+ Item extends PlainObject,
1761
+ ItemKey extends keyof Item,
1762
+ >(array: Item[], key: ItemKey, value: Item[ItemKey]): number;
1473
1763
  /**
1474
1764
  * Get the number of items _(count)_ that match the given value
1475
1765
  */
1476
- export declare function count<Item, Key extends (item: Item, index: number, array: Item[]) => Key>(array: Item[], key: Key, value: ReturnType<Key>): number;
1766
+ export declare function count<
1767
+ Item,
1768
+ ItemKey extends (item: Item, index: number, array: Item[]) => Key,
1769
+ >(array: Item[], key: ItemKey, value: ReturnType<ItemKey>): number;
1477
1770
  /**
1478
1771
  * Does the value exist in array?
1479
1772
  */
@@ -1481,17 +1774,26 @@ export declare function exists<Item>(array: Item[], value: Item): boolean;
1481
1774
  /**
1482
1775
  * Does the value exist in array?
1483
1776
  */
1484
- export declare function exists<Item>(array: Item[], matches: (item: Item, index: number, array: Item[]) => boolean): boolean;
1777
+ export declare function exists<Item>(
1778
+ array: Item[],
1779
+ matches: (item: Item, index: number, array: Item[]) => boolean,
1780
+ ): boolean;
1485
1781
  /**
1486
1782
  * - Does the value exist in array?
1487
1783
  * - Use `key` to find a comparison value to match with `value`
1488
1784
  */
1489
- export declare function exists<Item, Key extends keyof Item>(array: Item[], key: Key, value: Item[Key]): boolean;
1785
+ export declare function exists<
1786
+ Item extends PlainObject,
1787
+ ItemKey extends keyof Item,
1788
+ >(array: Item[], key: ItemKey, value: Item[ItemKey]): boolean;
1490
1789
  /**
1491
1790
  * - Does the value exist in array?
1492
1791
  * - Use `key` to find a comparison value to match with `value`
1493
1792
  */
1494
- export declare function exists<Item, Key extends (item: Item, index: number, array: Item[]) => Key>(array: Item[], key: Key, value: ReturnType<Key>): boolean;
1793
+ export declare function exists<
1794
+ Item,
1795
+ ItemKey extends (item: Item, index: number, array: Item[]) => Key,
1796
+ >(array: Item[], key: ItemKey, value: ReturnType<ItemKey>): boolean;
1495
1797
  /**
1496
1798
  * Get a filtered array of items matching `value`
1497
1799
  */
@@ -1499,83 +1801,192 @@ export declare function filter<Item>(array: Item[], value: Item): Item[];
1499
1801
  /**
1500
1802
  * Get a filtered array of items matching `value`
1501
1803
  */
1502
- export declare function filter<Item>(array: Item[], matches: (item: Item, index: number, array: Item[]) => boolean): Item[];
1804
+ export declare function filter<Item>(
1805
+ array: Item[],
1806
+ matches: (item: Item, index: number, array: Item[]) => boolean,
1807
+ ): Item[];
1503
1808
  /**
1504
1809
  * - Get a filtered array of items
1505
1810
  * - Use `key` to find a comparison value to match with `value`
1506
1811
  */
1507
- export declare function filter<Item, Key extends keyof Item>(array: Item[], key: Key, value: Item[Key]): Item[];
1812
+ export declare function filter<
1813
+ Item extends PlainObject,
1814
+ ItemKey extends keyof Item,
1815
+ >(array: Item[], key: ItemKey, value: Item[ItemKey]): Item[];
1508
1816
  /**
1509
1817
  * - Get a filtered array of items
1510
1818
  * - Use `key` to find a comparison value to match with `value`
1511
1819
  */
1512
- export declare function filter<Item, Key extends (item: Item, index: number, array: Item[]) => Key>(array: Item[], key: Key, value: ReturnType<Key>): Item[];
1820
+ export declare function filter<
1821
+ Item,
1822
+ ItemKey extends (item: Item, index: number, array: Item[]) => Key,
1823
+ >(array: Item[], key: ItemKey, value: ReturnType<ItemKey>): Item[];
1513
1824
  /**
1514
1825
  * Get the first item matching `value` _(or `undefined` if no match is found)_
1515
1826
  */
1516
- export declare function find<Item>(array: Item[], value: Item): Item | undefined;
1827
+ export declare function find<Item>(
1828
+ array: Item[],
1829
+ value: Item,
1830
+ ): Item | undefined;
1517
1831
  /**
1518
1832
  * Get the first item matching `value` _(or `undefined` if no match is found)_
1519
1833
  */
1520
- export declare function find<Item>(array: Item[], matches: (item: Item, index: number, array: Item[]) => boolean): Item | undefined;
1834
+ export declare function find<Item>(
1835
+ array: Item[],
1836
+ matches: (item: Item, index: number, array: Item[]) => boolean,
1837
+ ): Item | undefined;
1521
1838
  /**
1522
1839
  * - Get the first matching item _(or `undefined` if no match is found)_
1523
1840
  * - Use `key` to find a comparison value to match with `value`
1524
1841
  */
1525
- export declare function find<Item, Key extends keyof Item>(array: Item[], key: Key, value: Item[Key]): Item | undefined;
1842
+ export declare function find<
1843
+ Item extends PlainObject,
1844
+ ItemKey extends keyof Item,
1845
+ >(array: Item[], key: ItemKey, value: Item[ItemKey]): Item | undefined;
1526
1846
  /**
1527
1847
  * - Get the first matching item _(or `undefined` if no match is found)_
1528
1848
  * - Use `key` to find a comparison value to match with `value`
1529
1849
  */
1530
- export declare function find<Item, Key extends (item: Item, index: number, array: Item[]) => Key>(array: Item[], key: Key, value: ReturnType<Key>): Item | undefined;
1850
+ export declare function find<
1851
+ Item,
1852
+ ItemKey extends (item: Item, index: number, array: Item[]) => Key,
1853
+ >(array: Item[], key: ItemKey, value: ReturnType<ItemKey>): Item | undefined;
1531
1854
  /**
1532
1855
  * Create a record from an array of items using a specific key
1533
1856
  */
1534
- export declare function groupBy<Item, Key extends keyof Item>(array: Item[], key: Key): Record<KeyedValue<Item, Key>, Item>;
1857
+ export declare function groupBy<
1858
+ Item extends PlainObject,
1859
+ ItemKey extends keyof Item,
1860
+ >(array: Item[], key: ItemKey): Record<KeyedValue<Item, ItemKey>, Item>;
1535
1861
  /**
1536
1862
  * Create a record from an array of items using a specific key, and grouping them into arrays
1537
1863
  */
1538
- export declare function groupBy<Item, Key extends keyof Item>(array: Item[], key: Key, arrays: true): Record<KeyedValue<Item, Key>, Item[]>;
1864
+ export declare function groupBy<
1865
+ Item extends PlainObject,
1866
+ ItemKey extends keyof Item,
1867
+ >(
1868
+ array: Item[],
1869
+ key: ItemKey,
1870
+ arrays: true,
1871
+ ): Record<KeyedValue<Item, ItemKey>, Item[]>;
1539
1872
  /**
1540
1873
  * Create a record from an array of items using a specific key
1541
1874
  */
1542
- export declare function groupBy<Item, Key extends (item: Item, index: number, array: Item[]) => Key>(array: Item[], key: Key): Record<ReturnType<Key>, Item>;
1875
+ export declare function groupBy<
1876
+ Item,
1877
+ ItemKey extends (item: Item, index: number, array: Item[]) => Key,
1878
+ >(array: Item[], key: ItemKey): Record<ReturnType<ItemKey>, Item>;
1543
1879
  /**
1544
1880
  * Create a record from an array of items using a specific key, and grouping them into arrays
1545
1881
  */
1546
- export declare function groupBy<Item, Key extends (item: Item, index: number, array: Item[]) => Key>(array: Item[], key: Key, arrays: true): Record<ReturnType<Key>, Item[]>;
1882
+ export declare function groupBy<
1883
+ Item,
1884
+ ItemKey extends (item: Item, index: number, array: Item[]) => Key,
1885
+ >(
1886
+ array: Item[],
1887
+ key: ItemKey,
1888
+ arrays: true,
1889
+ ): Record<ReturnType<ItemKey>, Item[]>;
1547
1890
  /**
1548
1891
  * Create a record from an array of items using a specific key and value
1549
1892
  */
1550
- export declare function groupBy<Item, Key extends keyof Item, Value extends keyof Item>(array: Item[], key: Key, value: Value): Record<KeyedValue<Item, Key>, KeyedValue<Item, Value>>;
1893
+ export declare function groupBy<
1894
+ Item extends PlainObject,
1895
+ ItemKey extends keyof Item,
1896
+ ItemValue extends keyof Item,
1897
+ >(
1898
+ array: Item[],
1899
+ key: ItemKey,
1900
+ value: ItemValue,
1901
+ ): Record<KeyedValue<Item, ItemKey>, KeyedValue<Item, ItemValue>>;
1551
1902
  /**
1552
1903
  * Create a record from an array of items using a specific key and value, and grouping them into arrays
1553
1904
  */
1554
- export declare function groupBy<Item, Key extends keyof Item, Value extends keyof Item>(array: Item[], key: Key, value: Value, arrays: true): Record<KeyedValue<Item, Key>, Array<KeyedValue<Item, Value>>>;
1905
+ export declare function groupBy<
1906
+ Item extends PlainObject,
1907
+ ItemKey extends keyof Item,
1908
+ ItemValue extends keyof Item,
1909
+ >(
1910
+ array: Item[],
1911
+ key: ItemKey,
1912
+ value: ItemValue,
1913
+ arrays: true,
1914
+ ): Record<KeyedValue<Item, ItemKey>, Array<KeyedValue<Item, ItemValue>>>;
1555
1915
  /**
1556
1916
  * Create a record from an array of items using a specific key and value
1557
1917
  */
1558
- export declare function groupBy<Item, Key extends keyof Item, Value extends (item: Item, index: number, array: Item[]) => unknown>(array: Item[], key: Key, value: Value): Record<KeyedValue<Item, Key>, ReturnType<Value>>;
1918
+ export declare function groupBy<
1919
+ Item extends PlainObject,
1920
+ ItemKey extends keyof Item,
1921
+ ItemValue extends (item: Item, index: number, array: Item[]) => unknown,
1922
+ >(
1923
+ array: Item[],
1924
+ key: ItemKey,
1925
+ value: ItemValue,
1926
+ ): Record<KeyedValue<Item, ItemKey>, ReturnType<ItemValue>>;
1559
1927
  /**
1560
1928
  * Create a record from an array of items using a specific key and value, and grouping them into arrays
1561
1929
  */
1562
- export declare function groupBy<Item, Key extends keyof Item, Value extends (item: Item, index: number, array: Item[]) => unknown>(array: Item[], key: Key, value: Value, arrays: true): Record<KeyedValue<Item, Key>, Array<ReturnType<Value>>>;
1930
+ export declare function groupBy<
1931
+ Item extends PlainObject,
1932
+ ItemKey extends keyof Item,
1933
+ ItemValue extends (item: Item, index: number, array: Item[]) => unknown,
1934
+ >(
1935
+ array: Item[],
1936
+ key: ItemKey,
1937
+ value: ItemValue,
1938
+ arrays: true,
1939
+ ): Record<KeyedValue<Item, ItemKey>, Array<ReturnType<ItemValue>>>;
1563
1940
  /**
1564
1941
  * Create a record from an array of items using a specific key and value
1565
1942
  */
1566
- export declare function groupBy<Item, Key extends (item: Item, index: number, array: Item[]) => Key, Value extends keyof Item>(array: Item[], key: Key, value: Value): Record<ReturnType<Key>, KeyedValue<Item, Value>>;
1943
+ export declare function groupBy<
1944
+ Item extends PlainObject,
1945
+ ItemKey extends (item: Item, index: number, array: Item[]) => Key,
1946
+ ItemValue extends keyof Item,
1947
+ >(
1948
+ array: Item[],
1949
+ key: ItemKey,
1950
+ value: ItemValue,
1951
+ ): Record<ReturnType<ItemKey>, KeyedValue<Item, ItemValue>>;
1567
1952
  /**
1568
1953
  * Create a record from an array of items using a specific key and value, and grouping them into arrays
1569
1954
  */
1570
- export declare function groupBy<Item, Key extends (item: Item, index: number, array: Item[]) => Key, Value extends keyof Item>(array: Item[], key: Key, value: Value, arrays: true): Record<ReturnType<Key>, Array<KeyedValue<Item, Value>>>;
1955
+ export declare function groupBy<
1956
+ Item extends PlainObject,
1957
+ ItemKey extends (item: Item, index: number, array: Item[]) => Key,
1958
+ ItemValue extends keyof Item,
1959
+ >(
1960
+ array: Item[],
1961
+ key: ItemKey,
1962
+ value: ItemValue,
1963
+ arrays: true,
1964
+ ): Record<ReturnType<ItemKey>, Array<KeyedValue<Item, ItemValue>>>;
1571
1965
  /**
1572
1966
  * Create a record from an array of items using a specific key and value
1573
1967
  */
1574
- export declare function groupBy<Item, Key extends (item: Item, index: number, array: Item[]) => Key, Value extends (item: Item, index: number, array: Item[]) => unknown>(array: Item[], key: Key, value: Value): Record<ReturnType<Key>, ReturnType<Value>>;
1968
+ export declare function groupBy<
1969
+ Item,
1970
+ ItemKey extends (item: Item, index: number, array: Item[]) => Key,
1971
+ ItemValue extends (item: Item, index: number, array: Item[]) => unknown,
1972
+ >(
1973
+ array: Item[],
1974
+ key: ItemKey,
1975
+ value: ItemValue,
1976
+ ): Record<ReturnType<ItemKey>, ReturnType<ItemValue>>;
1575
1977
  /**
1576
1978
  * Create a record from an array of items using a specific key and value, and grouping them into arrays
1577
1979
  */
1578
- export declare function groupBy<Item, Key extends (item: Item, index: number, array: Item[]) => Key, Value extends (item: Item, index: number, array: Item[]) => unknown>(array: Item[], key: Key, value: Value, arrays: true): Record<ReturnType<Key>, Array<ReturnType<Value>>>;
1980
+ export declare function groupBy<
1981
+ Item,
1982
+ ItemKey extends (item: Item, index: number, array: Item[]) => Key,
1983
+ ItemValue extends (item: Item, index: number, array: Item[]) => unknown,
1984
+ >(
1985
+ array: Item[],
1986
+ key: ItemKey,
1987
+ value: ItemValue,
1988
+ arrays: true,
1989
+ ): Record<ReturnType<ItemKey>, Array<ReturnType<ItemValue>>>;
1579
1990
  /**
1580
1991
  * Get the index for the first item matching `value` _(or `-1` if no match is found)_
1581
1992
  */
@@ -1583,19 +1994,28 @@ export declare function indexOf<Item>(array: Item[], value: Item): number;
1583
1994
  /**
1584
1995
  * Get the index for the first item matching `value` _(or `-1` if no match is found)_
1585
1996
  */
1586
- export declare function indexOf<Item>(array: Item[], matches: (item: Item, index: number, array: Item[]) => boolean): number;
1997
+ export declare function indexOf<Item>(
1998
+ array: Item[],
1999
+ matches: (item: Item, index: number, array: Item[]) => boolean,
2000
+ ): number;
1587
2001
  /**
1588
2002
  * - Get the index for the first matching item _(or `-1` if no match is found)_
1589
2003
  * - Use `key` to find a comparison value to match with `value`
1590
2004
  */
1591
- export declare function indexOf<Item, Key extends keyof Item>(array: Item[], key: Key, value: Item[Key]): number;
2005
+ export declare function indexOf<
2006
+ Item extends PlainObject,
2007
+ ItemKey extends keyof Item,
2008
+ >(array: Item[], key: ItemKey, value: Item[ItemKey]): number;
1592
2009
  /**
1593
2010
  * - Get the index for the first matching item _(or `-1` if no match is found)_
1594
2011
  * - Use `key` to find a comparison value to match with `value`
1595
2012
  */
1596
- export declare function indexOf<Item, Key extends (item: Item, index: number, array: Item[]) => Key>(array: Item[], key: Key, value: ReturnType<Key>): number;
2013
+ export declare function indexOf<
2014
+ Item,
2015
+ ItemKey extends (item: Item, index: number, array: Item[]) => Key,
2016
+ >(array: Item[], key: ItemKey, value: ReturnType<ItemKey>): number;
1597
2017
  export type SortKey<Item> = {
1598
- direction: "asc" | "desc";
2018
+ direction: 'asc' | 'desc';
1599
2019
  value: Key | ((item: Item) => Key);
1600
2020
  };
1601
2021
  /**
@@ -1607,7 +2027,11 @@ export declare function insert<Item>(array: Item[], items: Item[]): void;
1607
2027
  * - Insert values into an array at a specified index
1608
2028
  * - _(Uses chunking to avoid stack overflow_)
1609
2029
  */
1610
- export declare function insert<Item>(array: Item[], index: number, items: Item[]): void;
2030
+ export declare function insert<Item>(
2031
+ array: Item[],
2032
+ index: number,
2033
+ items: Item[],
2034
+ ): void;
1611
2035
  /**
1612
2036
  * Shuffle an array
1613
2037
  */
@@ -1620,12 +2044,44 @@ export declare function sort<Item>(array: Item[], descending?: boolean): Item[];
1620
2044
  * - Sort an array of items, using a `key` to sort by a specific value
1621
2045
  * - Defaults to ascending, but can be changed by setting `descending` to `true`, or using a `SortKey`
1622
2046
  */
1623
- export declare function sort<Item>(array: Item[], key: Key | SortKey<Item> | ((item: Item) => Key), descending?: boolean): Item[];
2047
+ export declare function sort<Item>(
2048
+ array: Item[],
2049
+ key: Key | SortKey<Item> | ((item: Item) => Key),
2050
+ descending?: boolean,
2051
+ ): Item[];
2052
+ /**
2053
+ * - Sort an array of items, using a `key` to sort by a specific value
2054
+ * - Defaults to ascending, but can be changed by setting `descending` to `true`, or using a `SortKey`
2055
+ */
2056
+ export declare function sort<
2057
+ Item extends PlainObject,
2058
+ ItemKey extends keyof Item,
2059
+ >(
2060
+ array: Item[],
2061
+ key: ItemKey | Key | SortKey<Item> | ((item: Item) => Key),
2062
+ descending?: boolean,
2063
+ ): Item[];
2064
+ /**
2065
+ * - Sort an array of items, using multiple `keys` to sort by specific values
2066
+ * - Defaults to ascending, but can be changed by setting `descending` to `true`, or using `SortKey`
2067
+ */
2068
+ export declare function sort<Item>(
2069
+ array: Item[],
2070
+ keys: Array<Key | SortKey<Item> | ((item: Item) => Key)>,
2071
+ descending?: boolean,
2072
+ ): Item[];
1624
2073
  /**
1625
2074
  * - Sort an array of items, using multiple `keys` to sort by specific values
1626
2075
  * - Defaults to ascending, but can be changed by setting `descending` to `true`, or using `SortKey`
1627
2076
  */
1628
- export declare function sort<Item>(array: Item[], keys: Array<Key | SortKey<Item> | ((item: Item) => Key)>, descending?: boolean): Item[];
2077
+ export declare function sort<
2078
+ Item extends PlainObject,
2079
+ ItemKey extends keyof Item,
2080
+ >(
2081
+ array: Item[],
2082
+ keys: Array<ItemKey | Key | SortKey<Item> | ((item: Item) => Key)>,
2083
+ descending?: boolean,
2084
+ ): Item[];
1629
2085
  /**
1630
2086
  * Removes and returns all items from an array starting from a specific index
1631
2087
  */
@@ -1633,17 +2089,30 @@ export declare function splice<Item>(array: Item[], start: number): Item[];
1633
2089
  /**
1634
2090
  * Removes and returns _(up to)_ a specific amount of items from an array, starting from a specific index
1635
2091
  */
1636
- export declare function splice<Item>(array: Item[], start: number, amount: number): Item[];
2092
+ export declare function splice<Item>(
2093
+ array: Item[],
2094
+ start: number,
2095
+ amount: number,
2096
+ ): Item[];
1637
2097
  /**
1638
2098
  * - Splices values into an array and returns any removed values
1639
2099
  * - Uses chunking to avoid stack overflow
1640
2100
  */
1641
- export declare function splice<Item>(array: Item[], start: number, added: Item[]): Item[];
2101
+ export declare function splice<Item>(
2102
+ array: Item[],
2103
+ start: number,
2104
+ added: Item[],
2105
+ ): Item[];
1642
2106
  /**
1643
2107
  * - Splices values into an array and returns any removed values
1644
2108
  * - Uses chunking to avoid stack overflow
1645
2109
  */
1646
- export declare function splice<Item>(array: Item[], start: number, amount: number, added: Item[]): Item[];
2110
+ export declare function splice<Item>(
2111
+ array: Item[],
2112
+ start: number,
2113
+ amount: number,
2114
+ added: Item[],
2115
+ ): Item[];
1647
2116
  /**
1648
2117
  * Create a map from an array of items _(using their indices as keys)_
1649
2118
  */
@@ -1651,51 +2120,135 @@ export declare function toMap<Item>(array: Item[]): Map<number, Item>;
1651
2120
  /**
1652
2121
  * Create a map from an array of items using a specific key
1653
2122
  */
1654
- export declare function toMap<Item, Key extends keyof Item>(array: Item[], key: Key): Map<KeyedValue<Item, Key>, Item>;
2123
+ export declare function toMap<
2124
+ Item extends PlainObject,
2125
+ ItemKey extends keyof Item,
2126
+ >(array: Item[], key: ItemKey): Map<KeyedValue<Item, ItemKey>, Item>;
1655
2127
  /**
1656
2128
  * Create a map from an array of items using a specific key, and grouping them into arrays
1657
2129
  */
1658
- export declare function toMap<Item, Key extends keyof Item>(array: Item[], key: Key, arrays: true): Map<KeyedValue<Item, Key>, Item[]>;
2130
+ export declare function toMap<
2131
+ Item extends PlainObject,
2132
+ ItemKey extends keyof Item,
2133
+ >(
2134
+ array: Item[],
2135
+ key: ItemKey,
2136
+ arrays: true,
2137
+ ): Map<KeyedValue<Item, ItemKey>, Item[]>;
1659
2138
  /**
1660
2139
  * Create a map from an array of items using a specific key
1661
2140
  */
1662
- export declare function toMap<Item, Key extends (item: Item, index: number, array: Item[]) => Key>(array: Item[], key: Key): Map<ReturnType<Key>, Item>;
2141
+ export declare function toMap<
2142
+ Item,
2143
+ ItemKey extends (item: Item, index: number, array: Item[]) => Key,
2144
+ >(array: Item[], key: ItemKey): Map<ReturnType<ItemKey>, Item>;
1663
2145
  /**
1664
2146
  * Create a map from an array of items using a specific key, and grouping them into arrays
1665
2147
  */
1666
- export declare function toMap<Item, Key extends (item: Item, index: number, array: Item[]) => Key>(array: Item[], key: Key, arrays: true): Map<ReturnType<Key>, Item[]>;
2148
+ export declare function toMap<
2149
+ Item,
2150
+ ItemKey extends (item: Item, index: number, array: Item[]) => Key,
2151
+ >(array: Item[], key: ItemKey, arrays: true): Map<ReturnType<ItemKey>, Item[]>;
1667
2152
  /**
1668
2153
  * Create a map from an array of items using a specific key and value
1669
2154
  */
1670
- export declare function toMap<Item, Key extends keyof Item, Value extends keyof Item>(array: Item[], key: Key, value: Value): Map<KeyedValue<Item, Key>, KeyedValue<Item, Value>>;
2155
+ export declare function toMap<
2156
+ Item extends PlainObject,
2157
+ ItemKey extends keyof Item,
2158
+ ItemValue extends keyof Item,
2159
+ >(
2160
+ array: Item[],
2161
+ key: ItemKey,
2162
+ value: ItemValue,
2163
+ ): Map<KeyedValue<Item, ItemKey>, KeyedValue<Item, ItemValue>>;
1671
2164
  /**
1672
2165
  * Create a map from an array of items using a specific key and value, and grouping them into arrays
1673
2166
  */
1674
- export declare function toMap<Item, Key extends keyof Item, Value extends keyof Item>(array: Item[], key: Key, value: Value, arrays: true): Map<KeyedValue<Item, Key>, Array<KeyedValue<Item, Value>>>;
2167
+ export declare function toMap<
2168
+ Item extends PlainObject,
2169
+ ItemKey extends keyof Item,
2170
+ ItemValue extends keyof Item,
2171
+ >(
2172
+ array: Item[],
2173
+ key: ItemKey,
2174
+ value: ItemValue,
2175
+ arrays: true,
2176
+ ): Map<KeyedValue<Item, ItemKey>, Array<KeyedValue<Item, ItemValue>>>;
1675
2177
  /**
1676
2178
  * Create a map from an array of items using a specific key and value
1677
2179
  */
1678
- export declare function toMap<Item, Key extends keyof Item, Value extends (item: Item, index: number, array: Item[]) => unknown>(array: Item[], key: Key, value: Value): Map<KeyedValue<Item, Key>, ReturnType<Value>>;
2180
+ export declare function toMap<
2181
+ Item extends PlainObject,
2182
+ ItemKey extends keyof Item,
2183
+ ItemValue extends (item: Item, index: number, array: Item[]) => unknown,
2184
+ >(
2185
+ array: Item[],
2186
+ key: ItemKey,
2187
+ value: ItemValue,
2188
+ ): Map<KeyedValue<Item, ItemKey>, ReturnType<ItemValue>>;
1679
2189
  /**
1680
2190
  * Create a map from an array of items using a specific key and value, and grouping them into arrays
1681
2191
  */
1682
- export declare function toMap<Item, Key extends keyof Item, Value extends (item: Item, index: number, array: Item[]) => unknown>(array: Item[], key: Key, value: Value, arrays: true): Map<KeyedValue<Item, Key>, Array<ReturnType<Value>>>;
2192
+ export declare function toMap<
2193
+ Item extends PlainObject,
2194
+ ItemKey extends keyof Item,
2195
+ ItemValue extends (item: Item, index: number, array: Item[]) => unknown,
2196
+ >(
2197
+ array: Item[],
2198
+ key: ItemKey,
2199
+ value: ItemValue,
2200
+ arrays: true,
2201
+ ): Map<KeyedValue<Item, ItemKey>, Array<ReturnType<ItemValue>>>;
1683
2202
  /**
1684
2203
  * Create a map from an array of items using a specific key and value
1685
2204
  */
1686
- export declare function toMap<Item, Key extends (item: Item, index: number, array: Item[]) => Key, Value extends keyof Item>(array: Item[], key: Key, value: Value): Map<ReturnType<Key>, KeyedValue<Item, Value>>;
2205
+ export declare function toMap<
2206
+ Item extends PlainObject,
2207
+ ItemKey extends (item: Item, index: number, array: Item[]) => Key,
2208
+ ItemValue extends keyof Item,
2209
+ >(
2210
+ array: Item[],
2211
+ key: ItemKey,
2212
+ value: ItemValue,
2213
+ ): Map<ReturnType<ItemKey>, KeyedValue<Item, ItemValue>>;
1687
2214
  /**
1688
2215
  * Create a map from an array of items using a specific key and value, and grouping them into arrays
1689
2216
  */
1690
- export declare function toMap<Item, Key extends (item: Item, index: number, array: Item[]) => Key, Value extends keyof Item>(array: Item[], key: Key, value: Value, arrays: true): Map<ReturnType<Key>, Array<KeyedValue<Item, Value>>>;
2217
+ export declare function toMap<
2218
+ Item extends PlainObject,
2219
+ ItemKey extends (item: Item, index: number, array: Item[]) => Key,
2220
+ ItemValue extends keyof Item,
2221
+ >(
2222
+ array: Item[],
2223
+ key: ItemKey,
2224
+ value: ItemValue,
2225
+ arrays: true,
2226
+ ): Map<ReturnType<ItemKey>, Array<KeyedValue<Item, ItemValue>>>;
1691
2227
  /**
1692
2228
  * Create a map from an array of items using a specific key and value
1693
2229
  */
1694
- export declare function toMap<Item, Key extends (item: Item, index: number, array: Item[]) => Key, Value extends (item: Item, index: number, array: Item[]) => unknown>(array: Item[], key: Key, value: Value): Map<ReturnType<Key>, ReturnType<Value>>;
2230
+ export declare function toMap<
2231
+ Item,
2232
+ Key extends (item: Item, index: number, array: Item[]) => Key,
2233
+ Value extends (item: Item, index: number, array: Item[]) => unknown,
2234
+ >(
2235
+ array: Item[],
2236
+ key: Key,
2237
+ value: Value,
2238
+ ): Map<ReturnType<Key>, ReturnType<Value>>;
1695
2239
  /**
1696
2240
  * Create a map from an array of items using a specific key and value, and grouping them into arrays
1697
2241
  */
1698
- export declare function toMap<Item, Key extends (item: Item, index: number, array: Item[]) => Key, Value extends (item: Item, index: number, array: Item[]) => unknown>(array: Item[], key: Key, value: Value, arrays: true): Map<ReturnType<Key>, Array<ReturnType<Value>>>;
2242
+ export declare function toMap<
2243
+ Item,
2244
+ Key extends (item: Item, index: number, array: Item[]) => Key,
2245
+ Value extends (item: Item, index: number, array: Item[]) => unknown,
2246
+ >(
2247
+ array: Item[],
2248
+ key: Key,
2249
+ value: Value,
2250
+ arrays: true,
2251
+ ): Map<ReturnType<Key>, Array<ReturnType<Value>>>;
1699
2252
  /**
1700
2253
  * Create a record from an array of items _(using their indices as keys)_
1701
2254
  */
@@ -1703,51 +2256,139 @@ export declare function toRecord<Item>(array: Item[]): Record<number, Item>;
1703
2256
  /**
1704
2257
  * Create a record from an array of items using a specific key
1705
2258
  */
1706
- export declare function toRecord<Item, Key extends keyof Item>(array: Item[], key: Key): Record<KeyedValue<Item, Key>, Item>;
2259
+ export declare function toRecord<
2260
+ Item extends PlainObject,
2261
+ ItemKey extends keyof Item,
2262
+ >(array: Item[], key: ItemKey): Record<KeyedValue<Item, ItemKey>, Item>;
1707
2263
  /**
1708
2264
  * Create a record from an array of items using a specific key, and grouping them into arrays
1709
2265
  */
1710
- export declare function toRecord<Item, Key extends keyof Item>(array: Item[], key: Key, arrays: true): Record<KeyedValue<Item, Key>, Item[]>;
2266
+ export declare function toRecord<
2267
+ Item extends PlainObject,
2268
+ ItemKey extends keyof Item,
2269
+ >(
2270
+ array: Item[],
2271
+ key: ItemKey,
2272
+ arrays: true,
2273
+ ): Record<KeyedValue<Item, ItemKey>, Item[]>;
1711
2274
  /**
1712
2275
  * Create a record from an array of items using a specific key
1713
2276
  */
1714
- export declare function toRecord<Item, Key extends (item: Item, index: number, array: Item[]) => Key>(array: Item[], key: Key): Record<ReturnType<Key>, Item>;
2277
+ export declare function toRecord<
2278
+ Item,
2279
+ ItemKey extends (item: Item, index: number, array: Item[]) => Key,
2280
+ >(array: Item[], key: ItemKey): Record<ReturnType<ItemKey>, Item>;
1715
2281
  /**
1716
2282
  * Create a record from an array of items using a specific key, and grouping them into arrays
1717
2283
  */
1718
- export declare function toRecord<Item, Key extends (item: Item, index: number, array: Item[]) => Key>(array: Item[], key: Key, arrays: true): Record<ReturnType<Key>, Item[]>;
2284
+ export declare function toRecord<
2285
+ Item,
2286
+ ItemKey extends (item: Item, index: number, array: Item[]) => Key,
2287
+ >(
2288
+ array: Item[],
2289
+ key: ItemKey,
2290
+ arrays: true,
2291
+ ): Record<ReturnType<ItemKey>, Item[]>;
1719
2292
  /**
1720
2293
  * Create a record from an array of items using a specific key and value
1721
2294
  */
1722
- export declare function toRecord<Item, Key extends keyof Item, Value extends keyof Item>(array: Item[], key: Key, value: Value): Record<KeyedValue<Item, Key>, KeyedValue<Item, Value>>;
2295
+ export declare function toRecord<
2296
+ Item extends PlainObject,
2297
+ ItemKey extends keyof Item,
2298
+ ItemValue extends keyof Item,
2299
+ >(
2300
+ array: Item[],
2301
+ key: ItemKey,
2302
+ value: ItemValue,
2303
+ ): Record<KeyedValue<Item, ItemKey>, KeyedValue<Item, ItemValue>>;
1723
2304
  /**
1724
2305
  * Create a record from an array of items using a specific key and value, and grouping them into arrays
1725
2306
  */
1726
- export declare function toRecord<Item, Key extends keyof Item, Value extends keyof Item>(array: Item[], key: Key, value: Value, arrays: true): Record<KeyedValue<Item, Key>, Array<KeyedValue<Item, Value>>>;
2307
+ export declare function toRecord<
2308
+ Item extends PlainObject,
2309
+ ItemKey extends keyof Item,
2310
+ ItemValue extends keyof Item,
2311
+ >(
2312
+ array: Item[],
2313
+ key: ItemKey,
2314
+ value: ItemValue,
2315
+ arrays: true,
2316
+ ): Record<KeyedValue<Item, ItemKey>, Array<KeyedValue<Item, ItemValue>>>;
1727
2317
  /**
1728
2318
  * Create a record from an array of items using a specific key and value
1729
2319
  */
1730
- export declare function toRecord<Item, Key extends keyof Item, Value extends (item: Item, index: number, array: Item[]) => unknown>(array: Item[], key: Key, value: Value): Record<KeyedValue<Item, Key>, ReturnType<Value>>;
2320
+ export declare function toRecord<
2321
+ Item extends PlainObject,
2322
+ ItemKey extends keyof Item,
2323
+ ItemValue extends (item: Item, index: number, array: Item[]) => unknown,
2324
+ >(
2325
+ array: Item[],
2326
+ key: ItemKey,
2327
+ value: ItemValue,
2328
+ ): Record<KeyedValue<Item, ItemKey>, ReturnType<ItemValue>>;
1731
2329
  /**
1732
2330
  * Create a record from an array of items using a specific key and value, and grouping them into arrays
1733
2331
  */
1734
- export declare function toRecord<Item, Key extends keyof Item, Value extends (item: Item, index: number, array: Item[]) => unknown>(array: Item[], key: Key, value: Value, arrays: true): Record<KeyedValue<Item, Key>, Array<ReturnType<Value>>>;
2332
+ export declare function toRecord<
2333
+ Item extends PlainObject,
2334
+ ItemKey extends keyof Item,
2335
+ ItemValue extends (item: Item, index: number, array: Item[]) => unknown,
2336
+ >(
2337
+ array: Item[],
2338
+ key: ItemKey,
2339
+ value: ItemValue,
2340
+ arrays: true,
2341
+ ): Record<KeyedValue<Item, ItemKey>, Array<ReturnType<ItemValue>>>;
1735
2342
  /**
1736
2343
  * Create a record from an array of items using a specific key and value
1737
2344
  */
1738
- export declare function toRecord<Item, Key extends (item: Item, index: number, array: Item[]) => Key, Value extends keyof Item>(array: Item[], key: Key, value: Value): Record<ReturnType<Key>, KeyedValue<Item, Value>>;
2345
+ export declare function toRecord<
2346
+ Item extends PlainObject,
2347
+ ItemKey extends (item: Item, index: number, array: Item[]) => Key,
2348
+ ItemValue extends keyof Item,
2349
+ >(
2350
+ array: Item[],
2351
+ key: ItemKey,
2352
+ value: ItemValue,
2353
+ ): Record<ReturnType<ItemKey>, KeyedValue<Item, ItemValue>>;
1739
2354
  /**
1740
2355
  * Create a record from an array of items using a specific key and value, and grouping them into arrays
1741
2356
  */
1742
- export declare function toRecord<Item, Key extends (item: Item, index: number, array: Item[]) => Key, Value extends keyof Item>(array: Item[], key: Key, value: Value, arrays: true): Record<ReturnType<Key>, Array<KeyedValue<Item, Value>>>;
2357
+ export declare function toRecord<
2358
+ Item extends PlainObject,
2359
+ ItemKey extends (item: Item, index: number, array: Item[]) => Key,
2360
+ ItemValue extends keyof Item,
2361
+ >(
2362
+ array: Item[],
2363
+ key: ItemKey,
2364
+ value: ItemValue,
2365
+ arrays: true,
2366
+ ): Record<ReturnType<ItemKey>, Array<KeyedValue<Item, ItemValue>>>;
1743
2367
  /**
1744
2368
  * Create a record from an array of items using a specific key and value
1745
2369
  */
1746
- export declare function toRecord<Item, Key extends (item: Item, index: number, array: Item[]) => Key, Value extends (item: Item, index: number, array: Item[]) => unknown>(array: Item[], key: Key, value: Value): Record<ReturnType<Key>, ReturnType<Value>>;
2370
+ export declare function toRecord<
2371
+ Item,
2372
+ ItemKey extends (item: Item, index: number, array: Item[]) => Key,
2373
+ ItemValue extends (item: Item, index: number, array: Item[]) => unknown,
2374
+ >(
2375
+ array: Item[],
2376
+ key: ItemKey,
2377
+ value: ItemValue,
2378
+ ): Record<ReturnType<ItemKey>, ReturnType<ItemValue>>;
1747
2379
  /**
1748
2380
  * Create a record from an array of items using a specific key and value, and grouping them into arrays
1749
2381
  */
1750
- export declare function toRecord<Item, Key extends (item: Item, index: number, array: Item[]) => Key, Value extends (item: Item, index: number, array: Item[]) => unknown>(array: Item[], key: Key, value: Value, arrays: true): Record<ReturnType<Key>, Array<ReturnType<Value>>>;
2382
+ export declare function toRecord<
2383
+ Item,
2384
+ ItemKey extends (item: Item, index: number, array: Item[]) => Key,
2385
+ ItemValue extends (item: Item, index: number, array: Item[]) => unknown,
2386
+ >(
2387
+ array: Item[],
2388
+ key: ItemKey,
2389
+ value: ItemValue,
2390
+ arrays: true,
2391
+ ): Record<ReturnType<ItemKey>, Array<ReturnType<ItemValue>>>;
1751
2392
  /**
1752
2393
  * Get an array of unique items
1753
2394
  */
@@ -1756,12 +2397,18 @@ export declare function unique<Item>(array: Item[]): Item[];
1756
2397
  * - Get an array of unique items
1757
2398
  * - Use `key` to find a comparison value for an item
1758
2399
  */
1759
- export declare function unique<Item, Key extends keyof Item>(array: Item[], key: Key): Item[];
2400
+ export declare function unique<
2401
+ Item extends PlainObject,
2402
+ ItemKey extends keyof Item,
2403
+ >(array: Item[], key: ItemKey): Item[];
1760
2404
  /**
1761
2405
  * - Get an array of unique items
1762
2406
  * - Use `key` to find a comparison value for an item
1763
2407
  */
1764
- export declare function unique<Item, Key extends (item: Item, index: number, array: Item[]) => Key>(array: Item[], key: Key): Item[];
2408
+ export declare function unique<
2409
+ Item,
2410
+ ItemKey extends (item: Item, index: number, array: Item[]) => Key,
2411
+ >(array: Item[], key: ItemKey): Item[];
1765
2412
  /**
1766
2413
  * Flatten an array _(using native `flat` and maximum depth)_
1767
2414
  */
@@ -1864,7 +2511,12 @@ declare abstract class Colour<Model> {
1864
2511
  * Get the current value of the colour
1865
2512
  */
1866
2513
  get value(): Model;
1867
- constructor(type: string, value: Model, defaults: Model, properties: Array<keyof Model>);
2514
+ constructor(
2515
+ type: string,
2516
+ value: Model,
2517
+ defaults: Model,
2518
+ properties: Array<keyof Model>,
2519
+ );
1868
2520
  /**
1869
2521
  * Convert the colour to a hex-colour
1870
2522
  */
@@ -1936,7 +2588,9 @@ export declare function getRGBColour(value: RGBColourValue): RGBColour;
1936
2588
  /**
1937
2589
  * Is the value a colour?
1938
2590
  */
1939
- export declare function isColour(value: unknown): value is HexColour | HSLColour | RGBColour;
2591
+ export declare function isColour(
2592
+ value: unknown,
2593
+ ): value is HexColour | HSLColour | RGBColour;
1940
2594
  /**
1941
2595
  * Is the value a hex-colour?
1942
2596
  */
@@ -1987,7 +2641,10 @@ export declare class Emitter<Value> {
1987
2641
  }
1988
2642
  export declare class Observable<Value> {
1989
2643
  private readonly state;
1990
- constructor(emitter: Emitter<Value>, observers: Map<Subscription<Value>, Observer<Value>>);
2644
+ constructor(
2645
+ emitter: Emitter<Value>,
2646
+ observers: Map<Subscription<Value>, Observer<Value>>,
2647
+ );
1991
2648
  /**
1992
2649
  * Subscribe to value changes
1993
2650
  */
@@ -1995,7 +2652,11 @@ export declare class Observable<Value> {
1995
2652
  /**
1996
2653
  * Subscribe to value changes
1997
2654
  */
1998
- subscribe(onNext: (value: Value) => void, onError?: (error: Error) => void, onComplete?: () => void): Subscription<Value>;
2655
+ subscribe(
2656
+ onNext: (value: Value) => void,
2657
+ onError?: (error: Error) => void,
2658
+ onComplete?: () => void,
2659
+ ): Subscription<Value>;
1999
2660
  }
2000
2661
  export type ObservableState<Value> = {
2001
2662
  emitter: Emitter<Value>;
@@ -2079,11 +2740,16 @@ export type MemoisedState<Callback extends GenericCallback> = {
2079
2740
  * - Time is clamped between _0_ and _1000_ milliseconds
2080
2741
  * - Returns the callback with an added `cancel`-method for manually cancelling the debounce
2081
2742
  */
2082
- export declare function debounce<Callback extends GenericCallback>(callback: Callback, time?: number): Debounced<Callback>;
2743
+ export declare function debounce<Callback extends GenericCallback>(
2744
+ callback: Callback,
2745
+ time?: number,
2746
+ ): Debounced<Callback>;
2083
2747
  /**
2084
2748
  * Memoise a function, caching and retrieving results based on the first parameter
2085
2749
  */
2086
- export declare function memoise<Callback extends GenericCallback>(callback: Callback): Memoised<Callback>;
2750
+ export declare function memoise<Callback extends GenericCallback>(
2751
+ callback: Callback,
2752
+ ): Memoised<Callback>;
2087
2753
  /**
2088
2754
  * A function that does nothing, which can be useful, I guess…
2089
2755
  */
@@ -2092,7 +2758,10 @@ export declare function noop(): void;
2092
2758
  * - Throttle a function, ensuring it is only called once every `time` milliseconds
2093
2759
  * - Time is clamped between _0_ and _1000_ milliseconds
2094
2760
  */
2095
- export declare function throttle<Callback extends GenericCallback>(callback: Callback, time?: number): Callback;
2761
+ export declare function throttle<Callback extends GenericCallback>(
2762
+ callback: Callback,
2763
+ time?: number,
2764
+ ): Callback;
2096
2765
  /**
2097
2766
  * Convert a string to camel case _(thisIsCamelCase)_
2098
2767
  */
@@ -2130,7 +2799,11 @@ export type Options = {
2130
2799
  /**
2131
2800
  * Render a string from a template with variables
2132
2801
  */
2133
- export declare function template(value: string, variables: PlainObject, options?: Partial<Options>): string;
2802
+ export declare function template(
2803
+ value: string,
2804
+ variables: PlainObject,
2805
+ options?: Partial<Options>,
2806
+ ): string;
2134
2807
  /**
2135
2808
  * Create a new UUID
2136
2809
  */
@@ -2146,13 +2819,20 @@ export declare function join(value: unknown[], delimiter?: string): string;
2146
2819
  /**
2147
2820
  * Parse a JSON string into its proper value _(or `undefined` if it fails)_
2148
2821
  */
2149
- export declare function parse(value: string, reviver?: (this: unknown, key: string, value: unknown) => unknown): unknown;
2822
+ export declare function parse(
2823
+ value: string,
2824
+ reviver?: (this: unknown, key: string, value: unknown) => unknown,
2825
+ ): unknown;
2150
2826
  /**
2151
2827
  * Truncate a string to a specified length, when possible
2152
2828
  * - Returned as-is if the string is already short enough
2153
2829
  * - A suffix may be appended to the truncated string, e.g., an ellipsis
2154
2830
  */
2155
- export declare function truncate(value: string, length: number, suffix?: string): string;
2831
+ export declare function truncate(
2832
+ value: string,
2833
+ length: number,
2834
+ suffix?: string,
2835
+ ): string;
2156
2836
  /**
2157
2837
  * Split a string into words _(and other readable parts)_
2158
2838
  */
@@ -2160,12 +2840,12 @@ export declare function words(value: string): string[];
2160
2840
  /**
2161
2841
  * Clone any kind of value _(deeply, if needed)_
2162
2842
  */
2163
- export declare function clone(value: unknown): {} | null | undefined;
2843
+ export declare function clone<Value>(value: Value): Value;
2164
2844
  /**
2165
2845
  * Compare two values _(for sorting purposes)_
2166
2846
  */
2167
2847
  export declare function compare(first: unknown, second: unknown): number;
2168
- export type DiffType = "full" | "none" | "partial";
2848
+ export type DiffType = 'full' | 'none' | 'partial';
2169
2849
  export type DiffResult<First, Second = First> = {
2170
2850
  original: DiffValue<First, Second>;
2171
2851
  type: DiffType;
@@ -2185,11 +2865,18 @@ export type DiffValue<First = unknown, Second = First> = {
2185
2865
  * - `partial` if the values are partially different
2186
2866
  * - `values` holds the differences with dot notation keys
2187
2867
  */
2188
- export declare function diff<First, Second = First>(first: First, second: Second): DiffResult<First, Second>;
2868
+ export declare function diff<First, Second = First>(
2869
+ first: First,
2870
+ second: Second,
2871
+ ): DiffResult<First, Second>;
2189
2872
  /**
2190
2873
  * Are two strings equal? _(Case-sensitive by default)_
2191
2874
  */
2192
- export declare function equal(first: string, second: string, ignoreCase?: boolean): boolean;
2875
+ export declare function equal(
2876
+ first: string,
2877
+ second: string,
2878
+ ignoreCase?: boolean,
2879
+ ): boolean;
2193
2880
  /**
2194
2881
  * Are two values equal? _(Does a deep comparison, if needed)_
2195
2882
  */
@@ -2199,14 +2886,21 @@ export declare function equal(first: unknown, second: unknown): boolean;
2199
2886
  * - You can retrieve a nested value by using dot notation, e.g., `foo.bar.baz`
2200
2887
  * - Returns `undefined` if the value is not found
2201
2888
  */
2202
- export declare function getValue<Data extends PlainObject, Path extends Paths<Data>>(data: Data, path: Path): Get<Data, ToString<Path>>;
2889
+ export declare function getValue<
2890
+ Data extends ArrayOrPlainObject,
2891
+ Path extends Paths<Data>,
2892
+ >(data: Data, path: Path): Get<Data, ToString<Path>>;
2203
2893
  /**
2204
2894
  * - Get the value from an object using an unknown path
2205
2895
  * - You can retrieve a nested value by using dot notation, e.g., `foo.bar.baz`
2206
2896
  * - If `ignoreCase` is `true`, path matching will be case-insensitive
2207
2897
  * - Returns `undefined` if the value is not found
2208
2898
  */
2209
- export declare function getValue<Data extends PlainObject>(data: Data, path: string, ignoreCase?: boolean): unknown;
2899
+ export declare function getValue<Data extends ArrayOrPlainObject>(
2900
+ data: Data,
2901
+ path: string,
2902
+ ignoreCase?: boolean,
2903
+ ): unknown;
2210
2904
  export type MergeOptions = {
2211
2905
  /**
2212
2906
  * - Skip nullable values when merging arrays?
@@ -2217,14 +2911,20 @@ export type MergeOptions = {
2217
2911
  /**
2218
2912
  * Merge multiple arrays or objects into a single one
2219
2913
  */
2220
- export declare function merge<Model extends ArrayOrPlainObject>(values: Model[], options?: Partial<MergeOptions>): Model;
2914
+ export declare function merge<Model extends ArrayOrPlainObject>(
2915
+ values: Model[],
2916
+ options?: Partial<MergeOptions>,
2917
+ ): Model;
2221
2918
  /**
2222
2919
  * - Set the value in an object using a known path
2223
2920
  * - You can set a nested value by using dot notation, e.g., `foo.bar.baz`
2224
2921
  * - If a part of the path does not exist, it will be created, either as an array or a generic object, depending on the path
2225
2922
  * - Returns the original object
2226
2923
  */
2227
- export declare function setValue<Data extends PlainObject, Path extends Paths<Data>>(data: Data, path: Path, value: unknown): Data;
2924
+ export declare function setValue<
2925
+ Data extends ArrayOrPlainObject,
2926
+ Path extends Paths<Data>,
2927
+ >(data: Data, path: Path, value: unknown): Data;
2228
2928
  /**
2229
2929
  * - Set the value in an object using an unknown path
2230
2930
  * - You can set a nested value by using dot notation, e.g., `foo.bar.baz`
@@ -2232,24 +2932,41 @@ export declare function setValue<Data extends PlainObject, Path extends Paths<Da
2232
2932
  * - If `ignoreCase` is `true`, path matching will be case-insensitive
2233
2933
  * - Returns the original object
2234
2934
  */
2235
- export declare function setValue<Data extends PlainObject>(data: Data, path: string, value: unknown, ignoreCase?: boolean): Data;
2935
+ export declare function setValue<Data extends ArrayOrPlainObject>(
2936
+ data: Data,
2937
+ path: string,
2938
+ value: unknown,
2939
+ ignoreCase?: boolean,
2940
+ ): Data;
2236
2941
  export type Smushed<Value> = Simplify<{
2237
2942
  [Key in Paths<Value>]: Get<Value, ToString<Key>>;
2238
2943
  }>;
2239
2944
  /**
2240
2945
  * Smush an object into a flat object that uses dot notation keys
2241
2946
  */
2242
- export declare function smush<Value extends PlainObject>(value: Value): Smushed<Value>;
2243
- export type Unsmushed<Value extends PlainObject> = Simplify<Omit<{
2244
- [Key in KeysOfUnion<Value>]: Value[Key];
2245
- }, `${string}.${string}`>>;
2947
+ export declare function smush<Value extends PlainObject>(
2948
+ value: Value,
2949
+ ): Smushed<Value>;
2950
+ export type Unsmushed<Value extends PlainObject> = Simplify<
2951
+ Omit<
2952
+ {
2953
+ [Key in KeysOfUnion<Value>]: Value[Key];
2954
+ },
2955
+ `${string}.${string}`
2956
+ >
2957
+ >;
2246
2958
  /**
2247
2959
  * Unsmush a smushed object _(turning dot notation keys into nested keys)_
2248
2960
  */
2249
- export declare function unsmush<Value extends PlainObject>(value: Value): Unsmushed<Value>;
2961
+ export declare function unsmush<Value extends PlainObject>(
2962
+ value: Value,
2963
+ ): Unsmushed<Value>;
2250
2964
  /**
2251
2965
  * Create a new object with only the specified keys
2252
2966
  */
2253
- export declare function partial<Value extends PlainObject, Key extends keyof Value>(value: Value, keys: Key[]): Pick<Value, Key>;
2967
+ export declare function partial<
2968
+ Value extends PlainObject,
2969
+ Key extends keyof Value,
2970
+ >(value: Value, keys: Key[]): Pick<Value, Key>;
2254
2971
 
2255
2972
  export {};