@@ -19,7 +19,8 @@ export function findBy(...tests: Array<string | RegExp | Predicate<any>>) {
19
19
return < A > ( xs : A [ ] ) => xs . find ( testFn ) ! ;
20
20
}
21
21
22
- export const fetchText = ( path : string ) => fetch ( path ) . then ( ( res ) => res . text ( ) ) . catch ( ( ) => null ) ;
22
+ export const fetchText = ( path : string ) =>
23
+ fetch ( path ) . then ( ( res ) => res . text ( ) ) . catch ( ( ) => null ) ;
23
24
export const fetchJson = < R > ( path : string ) =>
24
25
fetch ( path ) . then ( ( res ) => res . json ( ) ) . catch ( ( ) => null ) as Promise < R > ;
25
26
@@ -81,10 +82,12 @@ const type = (obj: any, access: string): string => {
81
82
let ret = "any" ;
82
83
try {
83
84
ret = type ( obj ( ) , `ReturnType<${ access } >` ) ;
84
- } catch ( _ ) { }
85
+ } catch ( _ ) { }
85
86
return `()=>${ ret } ` ;
86
87
}
87
- const identifiers = "abcdefghijklmnopqrstuvwzyz_$" . split ( "" ) . map ( ( i ) => `${ i } :any` ) ;
88
+ const identifiers = "abcdefghijklmnopqrstuvwzyz_$" . split ( "" ) . map ( ( i ) =>
89
+ `${ i } :any`
90
+ ) ;
88
91
return `(${ identifiers . slice ( 0 , obj . length ) . join ( "," ) } )=>any` ;
89
92
}
90
93
case "object" : {
@@ -112,12 +115,13 @@ const type = (obj: any, access: string): string => {
112
115
}
113
116
const blacklist = [ "constructor" ] ;
114
117
return prototypes . reduce ( ( acc , p ) => {
115
- return `${ acc } &{${ Object . getOwnPropertyNames ( p )
116
- . filter ( ( k ) => ! blacklist . includes ( k ) )
117
- . sort ( )
118
- . map ( ( k ) => `"${ k } ":${ type ( obj [ k ] , `${ access } ["${ k } "]` ) } ` )
119
- . join ( ";" )
120
- } }`;
118
+ return `${ acc } &{${
119
+ Object . getOwnPropertyNames ( p )
120
+ . filter ( ( k ) => ! blacklist . includes ( k ) )
121
+ . sort ( )
122
+ . map ( ( k ) => `"${ k } ":${ type ( obj [ k ] , `${ access } ["${ k } "]` ) } ` )
123
+ . join ( ";" )
124
+ } }`;
121
125
} , "" ) ;
122
126
}
123
127
default :
@@ -136,7 +140,11 @@ const defaultOverride = (curr: any, val: any, key: any) => {
136
140
return val ;
137
141
} ;
138
142
139
- export function deepMerge < T , S > ( target : T , source : S , override = defaultOverride ) : T & S {
143
+ export function deepMerge < T , S > (
144
+ target : T ,
145
+ source : S ,
146
+ override = defaultOverride ,
147
+ ) : T & S {
140
148
// @ts -ignore
141
149
for ( const [ key , val ] of Object . entries ( source ) ) {
142
150
// @ts -ignore
@@ -158,7 +166,9 @@ export function deepMerge<T, S>(target: T, source: S, override = defaultOverride
158
166
return target ;
159
167
}
160
168
161
- export function stringifyUrlSearchParams ( params : Record < string , string | string [ ] > ) {
169
+ export function stringifyUrlSearchParams (
170
+ params : Record < string , string | string [ ] > ,
171
+ ) {
162
172
const searchParams = new URLSearchParams ( ) ;
163
173
for ( const [ key , value ] of Object . entries ( params ) ) {
164
174
if ( Array . isArray ( value ) ) {
@@ -175,12 +185,14 @@ export function stringifyUrlSearchParams(params: Record<string, string | string[
175
185
export class Transition {
176
186
private complete = true ;
177
187
private promise = Promise . resolve ( ) ;
178
- constructor ( ) { }
188
+ constructor ( ) { }
179
189
180
190
public extend ( ) {
181
191
this . complete = false ;
182
192
const p = Promise . withResolvers < void > ( ) ;
183
- this . promise = this . promise . then ( ( ) => p . promise ) . finally ( ( ) => this . complete = true ) ;
193
+ this . promise = this . promise . then ( ( ) => p . promise ) . finally ( ( ) =>
194
+ this . complete = true
195
+ ) ;
184
196
return p . resolve ;
185
197
}
186
198
@@ -208,7 +220,7 @@ const localProxyUrl = new URL(`http://${localProxyHost}/proxy/`);
208
220
export const localProxy = (
209
221
input : RequestInfo | URL ,
210
222
init : RequestInit = { } ,
211
- ) => {
223
+ ) : [ Request , RequestInit ] => {
212
224
let url : URL ;
213
225
if ( typeof input === "string" ) {
214
226
url = new URL ( input ) ;
@@ -241,7 +253,10 @@ export const localProxy = (
241
253
input . duplex = "half" ;
242
254
}
243
255
244
- const request = new Request ( url , input instanceof Request ? input : undefined ) ;
256
+ const request = new Request (
257
+ url ,
258
+ input instanceof Request ? input : undefined ,
259
+ ) ;
245
260
return [ request , init ] ;
246
261
} ;
247
262
@@ -280,7 +295,10 @@ export const proxy = (
280
295
input . duplex = "half" ;
281
296
}
282
297
283
- const request = new Request ( url , input instanceof Request ? input : undefined ) ;
298
+ const request = new Request (
299
+ url ,
300
+ input instanceof Request ? input : undefined ,
301
+ ) ;
284
302
return [ request , init ] ;
285
303
} ;
286
304
@@ -332,6 +350,9 @@ export const proxy2 = (
332
350
input . duplex = "half" ;
333
351
}
334
352
335
- const request = new Request ( url , input instanceof Request ? input : undefined ) ;
353
+ const request = new Request (
354
+ url ,
355
+ input instanceof Request ? input : undefined ,
356
+ ) ;
336
357
return [ request , init ] ;
337
358
} ;
0 commit comments