File tree Expand file tree Collapse file tree 1 file changed +8
-0
lines changed Expand file tree Collapse file tree 1 file changed +8
-0
lines changed Original file line number Diff line number Diff line change @@ -35,6 +35,9 @@ export type API<N extends string, D extends Definition> = {
35
35
instance : InternalInstance < N , D , keyof D > ,
36
36
options : MatchOptions < D , T >
37
37
) => T ;
38
+ def : < T > (
39
+ fn : ( x : InternalInstance < N , D , keyof D > ) => T ,
40
+ ) => ( x : InternalInstance < N , D , keyof D > ) => T
38
41
} ;
39
42
40
43
export type Is < R extends string > = `is${R } `;
@@ -89,6 +92,10 @@ function match(instance: any, options: any): any {
89
92
return options [ instance . tag ] ( instance . value ) ;
90
93
}
91
94
95
+ function def ( fn : any ) : any {
96
+ return ( x : any ) => fn ( x )
97
+ }
98
+
92
99
function otherwise ( tags :string [ ] ) {
93
100
return ( fn : any ) =>
94
101
Object . fromEntries (
@@ -233,6 +240,7 @@ export function type<N extends string, D extends Definition>(
233
240
fromPathSafe,
234
241
matchOr,
235
242
match,
243
+ def,
236
244
otherwise : ( ...args : any [ ] ) => {
237
245
if ( args . length === 0 ) {
238
246
return otherwise ( Object . keys ( routes ) )
You can’t perform that action at this time.
0 commit comments