File tree 1 file changed +18
-9
lines changed 1 file changed +18
-9
lines changed Original file line number Diff line number Diff line change @@ -25,15 +25,24 @@ import { Expect, Equal } from "../test";
25
25
*/
26
26
type GetRoute < Str extends string > = BuildRoute < Trim < Str > > ;
27
27
28
- type BuildRoute < Str extends string , DashCount extends number [ ] = [ ] > = Str extends `-${infer RestStr } `
29
- ? BuildRoute < RestStr , [ ...DashCount , 0 ] >
30
- : Str extends `${infer Destination } -${infer RestStr } `
31
- ? [ [ Destination , DashCount [ "length" ] ] , ...BuildRoute < RestStr , [ 0 ] > ]
32
- : Str extends ""
33
- ? [ ]
34
- : [ [ Str , DashCount [ "length" ] ] ] ;
35
-
36
- type Trim < Str extends string > = Str extends `-${infer RestStr } ` ? Trim < RestStr > : Str ;
28
+ // prettier-ignore
29
+ type BuildRoute <
30
+ Str extends string ,
31
+ DashCount extends number [ ] = [ ] ,
32
+ > = Str extends `-${infer RestStr } `
33
+ ? BuildRoute < RestStr , [ ...DashCount , 0 ] >
34
+ : Str extends `${infer Destination } -${infer RestStr } `
35
+ ? [ [ Destination , DashCount [ "length" ] ] , ...BuildRoute < RestStr , [ 0 ] > ]
36
+ : Str extends ""
37
+ ? [ ]
38
+ : [ [ Str , DashCount [ "length" ] ] ] ;
39
+
40
+ // prettier-ignore
41
+ type Trim < Str extends string > = Str extends `-${infer RestStr } `
42
+ ? Trim < RestStr >
43
+ : Str extends `${infer RestStr } -`
44
+ ? Trim < RestStr >
45
+ : Str ;
37
46
38
47
// *************************************************************************************
39
48
// *** Tests ***
You can’t perform that action at this time.
0 commit comments