@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.
- package/dist/js/array/chunk.cjs +1 -1
- package/dist/js/array/chunk.js +1 -1
- package/dist/js/value/equal.cjs +4 -1
- package/dist/js/value/equal.js +4 -1
- package/package.json +1 -1
- package/src/js/array/chunk.ts +1 -1
- package/src/js/array/count.ts +6 -6
- package/src/js/array/exists.ts +6 -6
- package/src/js/array/filter.ts +6 -6
- package/src/js/array/find.ts +6 -6
- package/src/js/array/group-by.ts +67 -55
- package/src/js/array/index-of.ts +6 -6
- package/src/js/array/sort.ts +20 -0
- package/src/js/array/to-map.ts +55 -47
- package/src/js/array/to-record.ts +61 -57
- package/src/js/array/unique.ts +6 -6
- package/src/js/internal/value/handle.ts +5 -5
- package/src/js/value/clone.ts +3 -1
- package/src/js/value/equal.ts +4 -1
- package/src/js/value/get.ts +9 -9
- package/src/js/value/set.ts +10 -11
- package/types/array/count.d.cts +34 -2
- package/types/array/count.d.ts +3 -3
- package/types/array/exists.d.cts +34 -2
- package/types/array/exists.d.ts +3 -3
- package/types/array/filter.d.cts +34 -2
- package/types/array/filter.d.ts +3 -3
- package/types/array/find.d.cts +34 -2
- package/types/array/find.d.ts +3 -3
- package/types/array/group-by.d.cts +44 -12
- package/types/array/group-by.d.ts +14 -14
- package/types/array/index-of.d.cts +34 -2
- package/types/array/index-of.d.ts +3 -3
- package/types/array/index.d.cts +88 -46
- package/types/array/sort.d.cts +42 -0
- package/types/array/sort.d.ts +11 -1
- package/types/array/to-map.d.cts +42 -10
- package/types/array/to-map.d.ts +13 -13
- package/types/array/to-record.d.cts +44 -12
- package/types/array/to-record.d.ts +13 -13
- package/types/array/unique.d.cts +34 -2
- package/types/array/unique.d.ts +3 -3
- package/types/index.d.cts +1034 -317
- package/types/internal/value/handle.d.cts +27 -2
- package/types/internal/value/handle.d.ts +2 -2
- package/types/models.d.cts +467 -210
- package/types/value/clone.d.cts +1 -1
- package/types/value/clone.d.ts +1 -1
- package/types/value/get.d.cts +470 -211
- package/types/value/get.d.ts +3 -3
- package/types/value/index.d.cts +515 -224
- package/types/value/set.d.cts +357 -170
- package/types/value/set.d.ts +3 -3
- package/types/value/smush.d.cts +463 -209
package/types/value/smush.d.cts
CHANGED
|
@@ -5,7 +5,14 @@ Matches any [primitive value](https://developer.mozilla.org/en-US/docs/Glossary/
|
|
|
5
5
|
|
|
6
6
|
@category Type
|
|
7
7
|
*/
|
|
8
|
-
export type Primitive =
|
|
8
|
+
export type Primitive =
|
|
9
|
+
| null
|
|
10
|
+
| undefined
|
|
11
|
+
| string
|
|
12
|
+
| number
|
|
13
|
+
| boolean
|
|
14
|
+
| symbol
|
|
15
|
+
| bigint;
|
|
9
16
|
declare const emptyObjectSymbol: unique symbol;
|
|
10
17
|
/**
|
|
11
18
|
Represents a strictly empty plain object, the `{}` value.
|
|
@@ -62,7 +69,11 @@ type Includes<Value extends readonly any[], Item> =
|
|
|
62
69
|
@category Type Guard
|
|
63
70
|
@category Utilities
|
|
64
71
|
*/
|
|
65
|
-
export type IsEqual<A, B> = (<G>() => G extends A ? 1 : 2) extends
|
|
72
|
+
export type IsEqual<A, B> = (<G>() => G extends A ? 1 : 2) extends <
|
|
73
|
+
G,
|
|
74
|
+
>() => G extends B ? 1 : 2
|
|
75
|
+
? true
|
|
76
|
+
: false;
|
|
66
77
|
/**
|
|
67
78
|
Represents an object with `unknown` value. You probably want this instead of `{}`.
|
|
68
79
|
|
|
@@ -189,14 +200,16 @@ type B = StaticPartOfArray<A>;
|
|
|
189
200
|
//=> [string, number, boolean]
|
|
190
201
|
```
|
|
191
202
|
*/
|
|
192
|
-
export type StaticPartOfArray<
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
203
|
+
export type StaticPartOfArray<
|
|
204
|
+
T extends UnknownArray,
|
|
205
|
+
Result extends UnknownArray = [],
|
|
206
|
+
> = T extends unknown
|
|
207
|
+
? number extends T['length']
|
|
208
|
+
? T extends readonly [infer U, ...infer V]
|
|
209
|
+
? StaticPartOfArray<V, [...Result, U]>
|
|
210
|
+
: Result
|
|
211
|
+
: T
|
|
212
|
+
: never; // Should never happen
|
|
200
213
|
/**
|
|
201
214
|
Returns the variable, non-fixed-length portion of the given array, excluding static-length parts.
|
|
202
215
|
|
|
@@ -207,12 +220,22 @@ type B = VariablePartOfArray<A>;
|
|
|
207
220
|
//=> string[]
|
|
208
221
|
```
|
|
209
222
|
*/
|
|
210
|
-
export type VariablePartOfArray<T extends UnknownArray> = T extends unknown
|
|
211
|
-
...StaticPartOfArray<T>,
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
export type StringDigit =
|
|
223
|
+
export type VariablePartOfArray<T extends UnknownArray> = T extends unknown
|
|
224
|
+
? T extends readonly [...StaticPartOfArray<T>, ...infer U]
|
|
225
|
+
? U
|
|
226
|
+
: []
|
|
227
|
+
: never; // Should never happen
|
|
228
|
+
export type StringDigit =
|
|
229
|
+
| '0'
|
|
230
|
+
| '1'
|
|
231
|
+
| '2'
|
|
232
|
+
| '3'
|
|
233
|
+
| '4'
|
|
234
|
+
| '5'
|
|
235
|
+
| '6'
|
|
236
|
+
| '7'
|
|
237
|
+
| '8'
|
|
238
|
+
| '9';
|
|
216
239
|
/**
|
|
217
240
|
Returns a boolean for whether the given type is `any`.
|
|
218
241
|
|
|
@@ -255,7 +278,7 @@ Please upvote [this issue](https://github.com/microsoft/TypeScript/issues/32277)
|
|
|
255
278
|
*/
|
|
256
279
|
// See https://github.com/microsoft/TypeScript/issues/31752
|
|
257
280
|
// eslint-disable-next-line @typescript-eslint/no-loss-of-precision
|
|
258
|
-
export type PositiveInfinity =
|
|
281
|
+
export type PositiveInfinity = 1e999;
|
|
259
282
|
/**
|
|
260
283
|
Matches the hidden `-Infinity` type.
|
|
261
284
|
|
|
@@ -267,7 +290,7 @@ Please upvote [this issue](https://github.com/microsoft/TypeScript/issues/32277)
|
|
|
267
290
|
*/
|
|
268
291
|
// See https://github.com/microsoft/TypeScript/issues/31752
|
|
269
292
|
// eslint-disable-next-line @typescript-eslint/no-loss-of-precision
|
|
270
|
-
export type NegativeInfinity = -
|
|
293
|
+
export type NegativeInfinity = -1e999;
|
|
271
294
|
/**
|
|
272
295
|
A negative `number`/`bigint` (`-∞ < x < 0`)
|
|
273
296
|
|
|
@@ -278,7 +301,11 @@ Use-case: Validating and documenting parameters.
|
|
|
278
301
|
|
|
279
302
|
@category Numeric
|
|
280
303
|
*/
|
|
281
|
-
export type Negative<T extends Numeric> = T extends Zero
|
|
304
|
+
export type Negative<T extends Numeric> = T extends Zero
|
|
305
|
+
? never
|
|
306
|
+
: `${T}` extends `-${string}`
|
|
307
|
+
? T
|
|
308
|
+
: never;
|
|
282
309
|
/**
|
|
283
310
|
Returns a boolean for whether the given number is a negative number.
|
|
284
311
|
|
|
@@ -294,7 +321,9 @@ type ShouldBeTrue = IsNegative<-1>;
|
|
|
294
321
|
|
|
295
322
|
@category Numeric
|
|
296
323
|
*/
|
|
297
|
-
export type IsNegative<T extends Numeric> = T extends Negative<T>
|
|
324
|
+
export type IsNegative<T extends Numeric> = T extends Negative<T>
|
|
325
|
+
? true
|
|
326
|
+
: false;
|
|
298
327
|
/**
|
|
299
328
|
Returns a boolean for whether two given types are both true.
|
|
300
329
|
|
|
@@ -315,11 +344,12 @@ And<true, false>;
|
|
|
315
344
|
*/
|
|
316
345
|
export type And<A extends boolean, B extends boolean> = [
|
|
317
346
|
A,
|
|
318
|
-
B
|
|
319
|
-
][number] extends true
|
|
320
|
-
|
|
321
|
-
IsEqual<B, false>
|
|
322
|
-
|
|
347
|
+
B,
|
|
348
|
+
][number] extends true
|
|
349
|
+
? true
|
|
350
|
+
: true extends [IsEqual<A, false>, IsEqual<B, false>][number]
|
|
351
|
+
? false
|
|
352
|
+
: never;
|
|
323
353
|
/**
|
|
324
354
|
Returns a boolean for whether either of two given types are true.
|
|
325
355
|
|
|
@@ -340,11 +370,12 @@ Or<false, false>;
|
|
|
340
370
|
*/
|
|
341
371
|
export type Or<A extends boolean, B extends boolean> = [
|
|
342
372
|
A,
|
|
343
|
-
B
|
|
344
|
-
][number] extends false
|
|
345
|
-
|
|
346
|
-
IsEqual<B, true>
|
|
347
|
-
|
|
373
|
+
B,
|
|
374
|
+
][number] extends false
|
|
375
|
+
? false
|
|
376
|
+
: true extends [IsEqual<A, true>, IsEqual<B, true>][number]
|
|
377
|
+
? true
|
|
378
|
+
: never;
|
|
348
379
|
/**
|
|
349
380
|
Returns a boolean for whether a given number is greater than another number.
|
|
350
381
|
|
|
@@ -362,32 +393,44 @@ GreaterThan<1, 5>;
|
|
|
362
393
|
//=> false
|
|
363
394
|
```
|
|
364
395
|
*/
|
|
365
|
-
export type GreaterThan<A extends number, B extends number> = number extends
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
]
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
] extends R
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
]
|
|
396
|
+
export type GreaterThan<A extends number, B extends number> = number extends
|
|
397
|
+
| A
|
|
398
|
+
| B
|
|
399
|
+
? never
|
|
400
|
+
: [
|
|
401
|
+
IsEqual<A, PositiveInfinity>,
|
|
402
|
+
IsEqual<A, NegativeInfinity>,
|
|
403
|
+
IsEqual<B, PositiveInfinity>,
|
|
404
|
+
IsEqual<B, NegativeInfinity>,
|
|
405
|
+
] extends infer R extends [boolean, boolean, boolean, boolean]
|
|
406
|
+
? Or<
|
|
407
|
+
And<IsEqual<R[0], true>, IsEqual<R[2], false>>,
|
|
408
|
+
And<IsEqual<R[3], true>, IsEqual<R[1], false>>
|
|
409
|
+
> extends true
|
|
410
|
+
? true
|
|
411
|
+
: Or<
|
|
412
|
+
And<IsEqual<R[1], true>, IsEqual<R[3], false>>,
|
|
413
|
+
And<IsEqual<R[2], true>, IsEqual<R[0], false>>
|
|
414
|
+
> extends true
|
|
415
|
+
? false
|
|
416
|
+
: true extends R[number]
|
|
417
|
+
? false
|
|
418
|
+
: [IsNegative<A>, IsNegative<B>] extends infer R extends [
|
|
419
|
+
boolean,
|
|
420
|
+
boolean,
|
|
421
|
+
]
|
|
422
|
+
? [true, false] extends R
|
|
423
|
+
? false
|
|
424
|
+
: [false, true] extends R
|
|
425
|
+
? true
|
|
426
|
+
: [false, false] extends R
|
|
427
|
+
? PositiveNumericStringGt<`${A}`, `${B}`>
|
|
428
|
+
: PositiveNumericStringGt<
|
|
429
|
+
`${NumberAbsolute<B>}`,
|
|
430
|
+
`${NumberAbsolute<A>}`
|
|
431
|
+
>
|
|
432
|
+
: never
|
|
433
|
+
: never;
|
|
391
434
|
/**
|
|
392
435
|
Returns a boolean for whether a given number is greater than or equal to another number.
|
|
393
436
|
|
|
@@ -405,7 +448,10 @@ GreaterThanOrEqual<1, 5>;
|
|
|
405
448
|
//=> false
|
|
406
449
|
```
|
|
407
450
|
*/
|
|
408
|
-
export type GreaterThanOrEqual<
|
|
451
|
+
export type GreaterThanOrEqual<
|
|
452
|
+
A extends number,
|
|
453
|
+
B extends number,
|
|
454
|
+
> = number extends A | B ? never : A extends B ? true : GreaterThan<A, B>;
|
|
409
455
|
/**
|
|
410
456
|
Returns a boolean for whether a given number is less than another number.
|
|
411
457
|
|
|
@@ -423,7 +469,11 @@ LessThan<1, 5>;
|
|
|
423
469
|
//=> true
|
|
424
470
|
```
|
|
425
471
|
*/
|
|
426
|
-
export type LessThan<A extends number, B extends number> = number extends A | B
|
|
472
|
+
export type LessThan<A extends number, B extends number> = number extends A | B
|
|
473
|
+
? never
|
|
474
|
+
: GreaterThanOrEqual<A, B> extends true
|
|
475
|
+
? false
|
|
476
|
+
: true;
|
|
427
477
|
/**
|
|
428
478
|
Create a tuple type of the given length `<L>` and fill it with the given type `<Fill>`.
|
|
429
479
|
|
|
@@ -431,11 +481,11 @@ If `<Fill>` is not provided, it will default to `unknown`.
|
|
|
431
481
|
|
|
432
482
|
@link https://itnext.io/implementing-arithmetic-within-typescripts-type-system-a1ef140a6f6f
|
|
433
483
|
*/
|
|
434
|
-
export type BuildTuple<
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
]>;
|
|
484
|
+
export type BuildTuple<
|
|
485
|
+
L extends number,
|
|
486
|
+
Fill = unknown,
|
|
487
|
+
T extends readonly unknown[] = [],
|
|
488
|
+
> = T['length'] extends L ? T : BuildTuple<L, Fill, [...T, Fill]>;
|
|
439
489
|
/**
|
|
440
490
|
Returns the maximum value from a tuple of integers.
|
|
441
491
|
|
|
@@ -451,10 +501,16 @@ ArrayMax<[1, 2, 5, 3, 99, -1]>;
|
|
|
451
501
|
//=> 99
|
|
452
502
|
```
|
|
453
503
|
*/
|
|
454
|
-
export type TupleMax<
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
504
|
+
export type TupleMax<
|
|
505
|
+
A extends number[],
|
|
506
|
+
Result extends number = NegativeInfinity,
|
|
507
|
+
> = number extends A[number]
|
|
508
|
+
? never
|
|
509
|
+
: A extends [infer F extends number, ...infer R extends number[]]
|
|
510
|
+
? GreaterThan<F, Result> extends true
|
|
511
|
+
? TupleMax<R, F>
|
|
512
|
+
: TupleMax<R, Result>
|
|
513
|
+
: Result;
|
|
458
514
|
/**
|
|
459
515
|
Returns the minimum value from a tuple of integers.
|
|
460
516
|
|
|
@@ -470,10 +526,16 @@ ArrayMin<[1, 2, 5, 3, -5]>;
|
|
|
470
526
|
//=> -5
|
|
471
527
|
```
|
|
472
528
|
*/
|
|
473
|
-
export type TupleMin<
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
529
|
+
export type TupleMin<
|
|
530
|
+
A extends number[],
|
|
531
|
+
Result extends number = PositiveInfinity,
|
|
532
|
+
> = number extends A[number]
|
|
533
|
+
? never
|
|
534
|
+
: A extends [infer F extends number, ...infer R extends number[]]
|
|
535
|
+
? LessThan<F, Result> extends true
|
|
536
|
+
? TupleMin<R, F>
|
|
537
|
+
: TupleMin<R, Result>
|
|
538
|
+
: Result;
|
|
477
539
|
/**
|
|
478
540
|
Return a string representation of the given string or number.
|
|
479
541
|
|
|
@@ -508,7 +570,14 @@ type NegativeInfinity = StringToNumber<'-Infinity'>;
|
|
|
508
570
|
@category Numeric
|
|
509
571
|
@category Template literal
|
|
510
572
|
*/
|
|
511
|
-
export type StringToNumber<S extends string> =
|
|
573
|
+
export type StringToNumber<S extends string> =
|
|
574
|
+
S extends `${infer N extends number}`
|
|
575
|
+
? N
|
|
576
|
+
: S extends 'Infinity'
|
|
577
|
+
? PositiveInfinity
|
|
578
|
+
: S extends '-Infinity'
|
|
579
|
+
? NegativeInfinity
|
|
580
|
+
: never;
|
|
512
581
|
/**
|
|
513
582
|
Returns an array of the characters of the string.
|
|
514
583
|
|
|
@@ -523,11 +592,14 @@ StringToArray<string>;
|
|
|
523
592
|
|
|
524
593
|
@category String
|
|
525
594
|
*/
|
|
526
|
-
export type StringToArray<
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
595
|
+
export type StringToArray<
|
|
596
|
+
S extends string,
|
|
597
|
+
Result extends string[] = [],
|
|
598
|
+
> = string extends S
|
|
599
|
+
? never
|
|
600
|
+
: S extends `${infer F}${infer R}`
|
|
601
|
+
? StringToArray<R, [...Result, F]>
|
|
602
|
+
: Result;
|
|
531
603
|
/**
|
|
532
604
|
Returns the length of the given string.
|
|
533
605
|
|
|
@@ -543,7 +615,9 @@ StringLength<string>;
|
|
|
543
615
|
@category String
|
|
544
616
|
@category Template literal
|
|
545
617
|
*/
|
|
546
|
-
export type StringLength<S extends string> = string extends S
|
|
618
|
+
export type StringLength<S extends string> = string extends S
|
|
619
|
+
? never
|
|
620
|
+
: StringToArray<S>['length'];
|
|
547
621
|
/**
|
|
548
622
|
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.
|
|
549
623
|
|
|
@@ -556,8 +630,17 @@ SameLengthPositiveNumericStringGt<'10', '10'>;
|
|
|
556
630
|
//=> false
|
|
557
631
|
```
|
|
558
632
|
*/
|
|
559
|
-
export type SameLengthPositiveNumericStringGt<
|
|
560
|
-
|
|
633
|
+
export type SameLengthPositiveNumericStringGt<
|
|
634
|
+
A extends string,
|
|
635
|
+
B extends string,
|
|
636
|
+
> = A extends `${infer FirstA}${infer RestA}`
|
|
637
|
+
? B extends `${infer FirstB}${infer RestB}`
|
|
638
|
+
? FirstA extends FirstB
|
|
639
|
+
? SameLengthPositiveNumericStringGt<RestA, RestB>
|
|
640
|
+
: PositiveNumericCharacterGt<FirstA, FirstB>
|
|
641
|
+
: never
|
|
642
|
+
: false;
|
|
643
|
+
export type NumericString = '0123456789';
|
|
561
644
|
/**
|
|
562
645
|
Returns a boolean for whether `A` is greater than `B`, where `A` and `B` are both positive numeric strings.
|
|
563
646
|
|
|
@@ -573,16 +656,21 @@ PositiveNumericStringGt<'1', '500'>;
|
|
|
573
656
|
//=> false
|
|
574
657
|
```
|
|
575
658
|
*/
|
|
576
|
-
export type PositiveNumericStringGt<
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
659
|
+
export type PositiveNumericStringGt<
|
|
660
|
+
A extends string,
|
|
661
|
+
B extends string,
|
|
662
|
+
> = A extends B
|
|
663
|
+
? false
|
|
664
|
+
: [
|
|
665
|
+
BuildTuple<StringLength<A>, 0>,
|
|
666
|
+
BuildTuple<StringLength<B>, 0>,
|
|
667
|
+
] extends infer R extends [readonly unknown[], readonly unknown[]]
|
|
668
|
+
? R[0] extends [...R[1], ...infer Remain extends readonly unknown[]]
|
|
669
|
+
? 0 extends Remain['length']
|
|
670
|
+
? SameLengthPositiveNumericStringGt<A, B>
|
|
671
|
+
: true
|
|
672
|
+
: false
|
|
673
|
+
: never;
|
|
586
674
|
/**
|
|
587
675
|
Returns a boolean for whether `A` represents a number greater than `B`, where `A` and `B` are both positive numeric characters.
|
|
588
676
|
|
|
@@ -595,7 +683,16 @@ PositiveNumericCharacterGt<'1', '1'>;
|
|
|
595
683
|
//=> false
|
|
596
684
|
```
|
|
597
685
|
*/
|
|
598
|
-
export type PositiveNumericCharacterGt<
|
|
686
|
+
export type PositiveNumericCharacterGt<
|
|
687
|
+
A extends string,
|
|
688
|
+
B extends string,
|
|
689
|
+
> = NumericString extends `${infer HeadA}${A}${infer TailA}`
|
|
690
|
+
? NumericString extends `${infer HeadB}${B}${infer TailB}`
|
|
691
|
+
? HeadA extends `${HeadB}${infer _}${infer __}`
|
|
692
|
+
? true
|
|
693
|
+
: false
|
|
694
|
+
: never
|
|
695
|
+
: never;
|
|
599
696
|
/**
|
|
600
697
|
Returns the absolute value of a given value.
|
|
601
698
|
|
|
@@ -611,7 +708,10 @@ NumberAbsolute<NegativeInfinity>
|
|
|
611
708
|
//=> PositiveInfinity
|
|
612
709
|
```
|
|
613
710
|
*/
|
|
614
|
-
export type NumberAbsolute<N extends number> =
|
|
711
|
+
export type NumberAbsolute<N extends number> =
|
|
712
|
+
`${N}` extends `-${infer StringPositiveN}`
|
|
713
|
+
? StringToNumber<StringPositiveN>
|
|
714
|
+
: N;
|
|
615
715
|
/**
|
|
616
716
|
Check whether the given type is a number or a number string.
|
|
617
717
|
|
|
@@ -631,7 +731,13 @@ type C = IsNumberLike<1>;
|
|
|
631
731
|
type D = IsNumberLike<'a'>;
|
|
632
732
|
//=> false
|
|
633
733
|
*/
|
|
634
|
-
export type IsNumberLike<N> = N extends number
|
|
734
|
+
export type IsNumberLike<N> = N extends number
|
|
735
|
+
? true
|
|
736
|
+
: N extends `${number}`
|
|
737
|
+
? true
|
|
738
|
+
: N extends `${number}.${number}`
|
|
739
|
+
? true
|
|
740
|
+
: false;
|
|
635
741
|
/**
|
|
636
742
|
Matches any primitive, `void`, `Date`, or `RegExp` value.
|
|
637
743
|
*/
|
|
@@ -639,7 +745,12 @@ export type BuiltIns = Primitive | void | Date | RegExp;
|
|
|
639
745
|
/**
|
|
640
746
|
Matches non-recursive types.
|
|
641
747
|
*/
|
|
642
|
-
export type NonRecursiveType =
|
|
748
|
+
export type NonRecursiveType =
|
|
749
|
+
| BuiltIns
|
|
750
|
+
| Function
|
|
751
|
+
| (new (
|
|
752
|
+
...arguments_: any[]
|
|
753
|
+
) => unknown);
|
|
643
754
|
/**
|
|
644
755
|
Returns the sum of two numbers.
|
|
645
756
|
|
|
@@ -671,35 +782,45 @@ Sum<PositiveInfinity, NegativeInfinity>;
|
|
|
671
782
|
@category Numeric
|
|
672
783
|
*/
|
|
673
784
|
// TODO: Support big integer and negative number.
|
|
674
|
-
export type Sum<A extends number, B extends number> = number extends A | B
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
785
|
+
export type Sum<A extends number, B extends number> = number extends A | B
|
|
786
|
+
? number
|
|
787
|
+
: [
|
|
788
|
+
IsEqual<A, PositiveInfinity>,
|
|
789
|
+
IsEqual<A, NegativeInfinity>,
|
|
790
|
+
IsEqual<B, PositiveInfinity>,
|
|
791
|
+
IsEqual<B, NegativeInfinity>,
|
|
792
|
+
] extends infer R extends [boolean, boolean, boolean, boolean]
|
|
793
|
+
? Or<
|
|
794
|
+
And<IsEqual<R[0], true>, IsEqual<R[3], false>>,
|
|
795
|
+
And<IsEqual<R[2], true>, IsEqual<R[1], false>>
|
|
796
|
+
> extends true
|
|
797
|
+
? PositiveInfinity
|
|
798
|
+
: Or<
|
|
799
|
+
And<IsEqual<R[1], true>, IsEqual<R[2], false>>,
|
|
800
|
+
And<IsEqual<R[3], true>, IsEqual<R[0], false>>
|
|
801
|
+
> extends true
|
|
802
|
+
? NegativeInfinity
|
|
803
|
+
: true extends R[number]
|
|
804
|
+
? number
|
|
805
|
+
: ([IsNegative<A>, IsNegative<B>] extends infer R
|
|
806
|
+
? [false, false] extends R
|
|
807
|
+
? [...BuildTuple<A>, ...BuildTuple<B>]['length']
|
|
808
|
+
: [true, true] extends R
|
|
809
|
+
? number
|
|
810
|
+
: TupleMax<
|
|
811
|
+
[NumberAbsolute<A>, NumberAbsolute<B>]
|
|
812
|
+
> extends infer Max_
|
|
813
|
+
? TupleMin<
|
|
814
|
+
[NumberAbsolute<A>, NumberAbsolute<B>]
|
|
815
|
+
> extends infer Min_ extends number
|
|
816
|
+
? Max_ extends A | B
|
|
817
|
+
? Subtract<Max_, Min_>
|
|
818
|
+
: number
|
|
819
|
+
: never
|
|
820
|
+
: never
|
|
821
|
+
: never) &
|
|
822
|
+
number
|
|
823
|
+
: never;
|
|
703
824
|
/**
|
|
704
825
|
Returns the difference between two numbers.
|
|
705
826
|
|
|
@@ -730,29 +851,40 @@ Subtract<PositiveInfinity, PositiveInfinity>;
|
|
|
730
851
|
@category Numeric
|
|
731
852
|
*/
|
|
732
853
|
// TODO: Support big integer and negative number.
|
|
733
|
-
export type Subtract<A extends number, B extends number> = number extends A | B
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
854
|
+
export type Subtract<A extends number, B extends number> = number extends A | B
|
|
855
|
+
? number
|
|
856
|
+
: [
|
|
857
|
+
IsEqual<A, PositiveInfinity>,
|
|
858
|
+
IsEqual<A, NegativeInfinity>,
|
|
859
|
+
IsEqual<B, PositiveInfinity>,
|
|
860
|
+
IsEqual<B, NegativeInfinity>,
|
|
861
|
+
] extends infer R extends [boolean, boolean, boolean, boolean]
|
|
862
|
+
? Or<
|
|
863
|
+
And<IsEqual<R[0], true>, IsEqual<R[2], false>>,
|
|
864
|
+
And<IsEqual<R[3], true>, IsEqual<R[1], false>>
|
|
865
|
+
> extends true
|
|
866
|
+
? PositiveInfinity
|
|
867
|
+
: Or<
|
|
868
|
+
And<IsEqual<R[1], true>, IsEqual<R[3], false>>,
|
|
869
|
+
And<IsEqual<R[2], true>, IsEqual<R[0], false>>
|
|
870
|
+
> extends true
|
|
871
|
+
? NegativeInfinity
|
|
872
|
+
: true extends R[number]
|
|
873
|
+
? number
|
|
874
|
+
: [IsNegative<A>, IsNegative<B>] extends infer R
|
|
875
|
+
? [false, false] extends R
|
|
876
|
+
? BuildTuple<A> extends infer R
|
|
877
|
+
? R extends [...BuildTuple<B>, ...infer R]
|
|
878
|
+
? R['length']
|
|
879
|
+
: number
|
|
880
|
+
: never
|
|
881
|
+
: LessThan<A, B> extends true
|
|
882
|
+
? number
|
|
883
|
+
: [false, true] extends R
|
|
884
|
+
? Sum<A, NumberAbsolute<B>>
|
|
885
|
+
: Subtract<NumberAbsolute<B>, NumberAbsolute<A>>
|
|
886
|
+
: never
|
|
887
|
+
: never;
|
|
756
888
|
/**
|
|
757
889
|
Paths options.
|
|
758
890
|
|
|
@@ -843,28 +975,85 @@ open('listB.1'); // TypeError. Because listB only has one element.
|
|
|
843
975
|
@category Object
|
|
844
976
|
@category Array
|
|
845
977
|
*/
|
|
846
|
-
export type Paths<T, Options extends PathsOptions = {}> = _Paths<
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
]
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
978
|
+
export type Paths<T, Options extends PathsOptions = {}> = _Paths<
|
|
979
|
+
T,
|
|
980
|
+
{
|
|
981
|
+
// Set default maxRecursionDepth to 10
|
|
982
|
+
maxRecursionDepth: Options['maxRecursionDepth'] extends number
|
|
983
|
+
? Options['maxRecursionDepth']
|
|
984
|
+
: DefaultPathsOptions['maxRecursionDepth'];
|
|
985
|
+
// Set default bracketNotation to false
|
|
986
|
+
bracketNotation: Options['bracketNotation'] extends boolean
|
|
987
|
+
? Options['bracketNotation']
|
|
988
|
+
: DefaultPathsOptions['bracketNotation'];
|
|
989
|
+
}
|
|
990
|
+
>;
|
|
991
|
+
export type _Paths<T, Options extends Required<PathsOptions>> = T extends
|
|
992
|
+
| NonRecursiveType
|
|
993
|
+
| ReadonlyMap<unknown, unknown>
|
|
994
|
+
| ReadonlySet<unknown>
|
|
995
|
+
? never
|
|
996
|
+
: IsAny<T> extends true
|
|
997
|
+
? never
|
|
998
|
+
: T extends UnknownArray
|
|
999
|
+
? number extends T['length']
|
|
1000
|
+
?
|
|
1001
|
+
| InternalPaths<StaticPartOfArray<T>, Options>
|
|
1002
|
+
| InternalPaths<Array<VariablePartOfArray<T>[number]>, Options>
|
|
1003
|
+
: InternalPaths<T, Options>
|
|
1004
|
+
: T extends object
|
|
1005
|
+
? InternalPaths<T, Options>
|
|
1006
|
+
: never;
|
|
1007
|
+
export type InternalPaths<
|
|
1008
|
+
T,
|
|
1009
|
+
Options extends Required<PathsOptions>,
|
|
1010
|
+
> = Options['maxRecursionDepth'] extends infer MaxDepth extends number
|
|
1011
|
+
? Required<T> extends infer T
|
|
1012
|
+
? T extends EmptyObject | readonly []
|
|
1013
|
+
? never
|
|
1014
|
+
: {
|
|
1015
|
+
[Key in keyof T]: Key extends string | number // Limit `Key` to string or number.
|
|
1016
|
+
? (
|
|
1017
|
+
Options['bracketNotation'] extends true
|
|
1018
|
+
? IsNumberLike<Key> extends true
|
|
1019
|
+
? `[${Key}]`
|
|
1020
|
+
: Key | ToString<Key>
|
|
1021
|
+
: never | Options['bracketNotation'] extends false
|
|
1022
|
+
? Key | ToString<Key>
|
|
1023
|
+
: never
|
|
1024
|
+
) extends infer TranformedKey extends string | number
|
|
1025
|
+
? // 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
|
|
1026
|
+
// 2. If style is 'a.0.b', transform 'Key' to `${Key}` | Key
|
|
1027
|
+
| TranformedKey
|
|
1028
|
+
// Recursively generate paths for the current key
|
|
1029
|
+
| (GreaterThan<MaxDepth, 0> extends true // Limit the depth to prevent infinite recursion
|
|
1030
|
+
? _Paths<
|
|
1031
|
+
T[Key],
|
|
1032
|
+
{
|
|
1033
|
+
bracketNotation: Options['bracketNotation'];
|
|
1034
|
+
maxRecursionDepth: Subtract<MaxDepth, 1>;
|
|
1035
|
+
}
|
|
1036
|
+
> extends infer SubPath
|
|
1037
|
+
? SubPath extends string | number
|
|
1038
|
+
?
|
|
1039
|
+
| (Options['bracketNotation'] extends true
|
|
1040
|
+
? SubPath extends
|
|
1041
|
+
| `[${any}]`
|
|
1042
|
+
| `[${any}]${string}`
|
|
1043
|
+
? `${TranformedKey}${SubPath}` // If next node is number key like `[3]`, no need to add `.` before it.
|
|
1044
|
+
: `${TranformedKey}.${SubPath}`
|
|
1045
|
+
: never)
|
|
1046
|
+
| (Options['bracketNotation'] extends false
|
|
1047
|
+
? `${TranformedKey}.${SubPath}`
|
|
1048
|
+
: never)
|
|
1049
|
+
: never
|
|
1050
|
+
: never
|
|
1051
|
+
: never)
|
|
1052
|
+
: never
|
|
1053
|
+
: never;
|
|
1054
|
+
}[keyof T & (T extends UnknownArray ? number : unknown)]
|
|
1055
|
+
: never
|
|
1056
|
+
: never;
|
|
868
1057
|
export type LiteralStringUnion<T> = LiteralUnion<T, string>;
|
|
869
1058
|
/**
|
|
870
1059
|
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.
|
|
@@ -895,7 +1084,9 @@ const pet: Pet2 = '';
|
|
|
895
1084
|
|
|
896
1085
|
@category Type
|
|
897
1086
|
*/
|
|
898
|
-
export type LiteralUnion<LiteralType, BaseType extends Primitive> =
|
|
1087
|
+
export type LiteralUnion<LiteralType, BaseType extends Primitive> =
|
|
1088
|
+
| LiteralType
|
|
1089
|
+
| (BaseType & Record<never, never>);
|
|
899
1090
|
/**
|
|
900
1091
|
Get keys of the given type as strings.
|
|
901
1092
|
|
|
@@ -920,7 +1111,8 @@ type StringKeysOfFoo = StringKeyOf<Foo>;
|
|
|
920
1111
|
|
|
921
1112
|
@category Object
|
|
922
1113
|
*/
|
|
923
|
-
export type StringKeyOf<BaseType> =
|
|
1114
|
+
export type StringKeyOf<BaseType> =
|
|
1115
|
+
`${Extract<keyof BaseType, string | number>}`;
|
|
924
1116
|
/**
|
|
925
1117
|
Represents an array of strings split using a given character or character set.
|
|
926
1118
|
|
|
@@ -942,13 +1134,14 @@ array = split(items, ',');
|
|
|
942
1134
|
@category String
|
|
943
1135
|
@category Template literal
|
|
944
1136
|
*/
|
|
945
|
-
export type Split<
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
S
|
|
951
|
-
]
|
|
1137
|
+
export type Split<
|
|
1138
|
+
S extends string,
|
|
1139
|
+
Delimiter extends string,
|
|
1140
|
+
> = S extends `${infer Head}${Delimiter}${infer Tail}`
|
|
1141
|
+
? [Head, ...Split<Tail, Delimiter>]
|
|
1142
|
+
: S extends Delimiter
|
|
1143
|
+
? []
|
|
1144
|
+
: [S];
|
|
952
1145
|
export type GetOptions = {
|
|
953
1146
|
/**
|
|
954
1147
|
Include `undefined` in the return type when accessing properties.
|
|
@@ -962,24 +1155,41 @@ export type GetOptions = {
|
|
|
962
1155
|
/**
|
|
963
1156
|
Like the `Get` type but receives an array of strings as a path parameter.
|
|
964
1157
|
*/
|
|
965
|
-
export type GetWithPath<
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
1158
|
+
export type GetWithPath<
|
|
1159
|
+
BaseType,
|
|
1160
|
+
Keys,
|
|
1161
|
+
Options extends GetOptions = {},
|
|
1162
|
+
> = Keys extends readonly []
|
|
1163
|
+
? BaseType
|
|
1164
|
+
: Keys extends readonly [infer Head, ...infer Tail]
|
|
1165
|
+
? GetWithPath<
|
|
1166
|
+
PropertyOf<BaseType, Extract<Head, string>, Options>,
|
|
1167
|
+
Extract<Tail, string[]>,
|
|
1168
|
+
Options
|
|
1169
|
+
>
|
|
1170
|
+
: never;
|
|
970
1171
|
/**
|
|
971
1172
|
Adds `undefined` to `Type` if `strict` is enabled.
|
|
972
1173
|
*/
|
|
973
|
-
export type Strictify<
|
|
1174
|
+
export type Strictify<
|
|
1175
|
+
Type,
|
|
1176
|
+
Options extends GetOptions,
|
|
1177
|
+
> = Options['strict'] extends false ? Type : Type | undefined;
|
|
974
1178
|
/**
|
|
975
1179
|
If `Options['strict']` is `true`, includes `undefined` in the returned type when accessing properties on `Record<string, any>`.
|
|
976
1180
|
|
|
977
1181
|
Known limitations:
|
|
978
1182
|
- Does not include `undefined` in the type on object types with an index signature (for example, `{a: string; [key: string]: string}`).
|
|
979
1183
|
*/
|
|
980
|
-
export type StrictPropertyOf<
|
|
981
|
-
|
|
982
|
-
|
|
1184
|
+
export type StrictPropertyOf<
|
|
1185
|
+
BaseType,
|
|
1186
|
+
Key extends keyof BaseType,
|
|
1187
|
+
Options extends GetOptions,
|
|
1188
|
+
> = Record<string, any> extends BaseType
|
|
1189
|
+
? string extends keyof BaseType
|
|
1190
|
+
? Strictify<BaseType[Key], Options> // Record<string, any>
|
|
1191
|
+
: BaseType[Key] // Record<'a' | 'b', any> (Records with a string union as keys have required properties)
|
|
1192
|
+
: BaseType[Key];
|
|
983
1193
|
/**
|
|
984
1194
|
Splits a dot-prop style path into a tuple comprised of the properties in the path. Handles square-bracket notation.
|
|
985
1195
|
|
|
@@ -992,11 +1202,18 @@ ToPath<'foo[0].bar.baz'>
|
|
|
992
1202
|
//=> ['foo', '0', 'bar', 'baz']
|
|
993
1203
|
```
|
|
994
1204
|
*/
|
|
995
|
-
export type ToPath<S extends string> = Split<FixPathSquareBrackets<S>,
|
|
1205
|
+
export type ToPath<S extends string> = Split<FixPathSquareBrackets<S>, '.'>;
|
|
996
1206
|
/**
|
|
997
1207
|
Replaces square-bracketed dot notation with dots, for example, `foo[0].bar` -> `foo.0.bar`.
|
|
998
1208
|
*/
|
|
999
|
-
export type FixPathSquareBrackets<Path extends string> =
|
|
1209
|
+
export type FixPathSquareBrackets<Path extends string> =
|
|
1210
|
+
Path extends `[${infer Head}]${infer Tail}`
|
|
1211
|
+
? Tail extends `[${string}`
|
|
1212
|
+
? `${Head}.${FixPathSquareBrackets<Tail>}`
|
|
1213
|
+
: `${Head}${FixPathSquareBrackets<Tail>}`
|
|
1214
|
+
: Path extends `${infer Head}[${infer Middle}]${infer Tail}`
|
|
1215
|
+
? `${Head}.${FixPathSquareBrackets<`[${Middle}]${Tail}`>}`
|
|
1216
|
+
: Path;
|
|
1000
1217
|
/**
|
|
1001
1218
|
Returns true if `LongString` is made up out of `Substring` repeated 0 or more times.
|
|
1002
1219
|
|
|
@@ -1008,7 +1225,14 @@ ConsistsOnlyOf<'aBa', 'a'> //=> false
|
|
|
1008
1225
|
ConsistsOnlyOf<'', 'a'> //=> true
|
|
1009
1226
|
```
|
|
1010
1227
|
*/
|
|
1011
|
-
export type ConsistsOnlyOf<
|
|
1228
|
+
export type ConsistsOnlyOf<
|
|
1229
|
+
LongString extends string,
|
|
1230
|
+
Substring extends string,
|
|
1231
|
+
> = LongString extends ''
|
|
1232
|
+
? true
|
|
1233
|
+
: LongString extends `${Substring}${infer Tail}`
|
|
1234
|
+
? ConsistsOnlyOf<Tail, Substring>
|
|
1235
|
+
: false;
|
|
1012
1236
|
/**
|
|
1013
1237
|
Convert a type which may have number keys to one with string keys, making it possible to index using strings retrieved from template types.
|
|
1014
1238
|
|
|
@@ -1029,11 +1253,11 @@ export type WithStringKeys<BaseType> = {
|
|
|
1029
1253
|
/**
|
|
1030
1254
|
Perform a `T[U]` operation if `T` supports indexing.
|
|
1031
1255
|
*/
|
|
1032
|
-
export type UncheckedIndex<T, U extends string | number> = [
|
|
1033
|
-
|
|
1034
|
-
]
|
|
1035
|
-
|
|
1036
|
-
|
|
1256
|
+
export type UncheckedIndex<T, U extends string | number> = [T] extends [
|
|
1257
|
+
Record<string | number, any>,
|
|
1258
|
+
]
|
|
1259
|
+
? T[U]
|
|
1260
|
+
: never;
|
|
1037
1261
|
/**
|
|
1038
1262
|
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.
|
|
1039
1263
|
|
|
@@ -1041,15 +1265,26 @@ Note:
|
|
|
1041
1265
|
- 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.
|
|
1042
1266
|
- Returns `undefined` from nullish values, to match the behaviour of most deep-key libraries like `lodash`, `dot-prop`, etc.
|
|
1043
1267
|
*/
|
|
1044
|
-
export type PropertyOf<
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1268
|
+
export type PropertyOf<
|
|
1269
|
+
BaseType,
|
|
1270
|
+
Key extends string,
|
|
1271
|
+
Options extends GetOptions = {},
|
|
1272
|
+
> = BaseType extends null | undefined
|
|
1273
|
+
? undefined
|
|
1274
|
+
: Key extends keyof BaseType
|
|
1275
|
+
? StrictPropertyOf<BaseType, Key, Options>
|
|
1276
|
+
: BaseType extends readonly [] | readonly [unknown, ...unknown[]]
|
|
1277
|
+
? unknown // It's a tuple, but `Key` did not extend `keyof BaseType`. So the index is out of bounds.
|
|
1278
|
+
: BaseType extends {
|
|
1279
|
+
[n: number]: infer Item;
|
|
1280
|
+
length: number; // Note: This is needed to avoid being too lax with records types using number keys like `{0: string; 1: boolean}`.
|
|
1281
|
+
}
|
|
1282
|
+
? ConsistsOnlyOf<Key, StringDigit> extends true
|
|
1283
|
+
? Strictify<Item, Options>
|
|
1284
|
+
: unknown
|
|
1285
|
+
: Key extends keyof WithStringKeys<BaseType>
|
|
1286
|
+
? StrictPropertyOf<WithStringKeys<BaseType>, Key, Options>
|
|
1287
|
+
: unknown;
|
|
1053
1288
|
// 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.
|
|
1054
1289
|
/**
|
|
1055
1290
|
Get a deeply-nested property from an object using a key path, like Lodash's `.get()` function.
|
|
@@ -1097,11 +1332,28 @@ Get<Record<string, string>, 'foo', {strict: true}> // => string
|
|
|
1097
1332
|
@category Array
|
|
1098
1333
|
@category Template literal
|
|
1099
1334
|
*/
|
|
1100
|
-
export type Get<
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1335
|
+
export type Get<
|
|
1336
|
+
BaseType,
|
|
1337
|
+
Path extends
|
|
1338
|
+
| readonly string[]
|
|
1339
|
+
| LiteralStringUnion<
|
|
1340
|
+
ToString<
|
|
1341
|
+
| Paths<
|
|
1342
|
+
BaseType,
|
|
1343
|
+
{
|
|
1344
|
+
bracketNotation: false;
|
|
1345
|
+
}
|
|
1346
|
+
>
|
|
1347
|
+
| Paths<
|
|
1348
|
+
BaseType,
|
|
1349
|
+
{
|
|
1350
|
+
bracketNotation: true;
|
|
1351
|
+
}
|
|
1352
|
+
>
|
|
1353
|
+
>
|
|
1354
|
+
>,
|
|
1355
|
+
Options extends GetOptions = {},
|
|
1356
|
+
> = GetWithPath<BaseType, Path extends string ? ToPath<Path> : Path, Options>;
|
|
1105
1357
|
export type PlainObject = UnknownRecord;
|
|
1106
1358
|
export type Smushed<Value> = Simplify<{
|
|
1107
1359
|
[Key in Paths<Value>]: Get<Value, ToString<Key>>;
|
|
@@ -1109,6 +1361,8 @@ export type Smushed<Value> = Simplify<{
|
|
|
1109
1361
|
/**
|
|
1110
1362
|
* Smush an object into a flat object that uses dot notation keys
|
|
1111
1363
|
*/
|
|
1112
|
-
export declare function smush<Value extends PlainObject>(
|
|
1364
|
+
export declare function smush<Value extends PlainObject>(
|
|
1365
|
+
value: Value,
|
|
1366
|
+
): Smushed<Value>;
|
|
1113
1367
|
|
|
1114
1368
|
export {};
|