File tree Expand file tree Collapse file tree 1 file changed +1
-32
lines changed Expand file tree Collapse file tree 1 file changed +1
-32
lines changed Original file line number Diff line number Diff line change 33import { NullableHeaders } from './headers' ;
44
55import type { BodyInit } from './builtin-types' ;
6- import { isEmptyObj , hasOwn } from './utils/values' ;
76import { Stream } from '../streaming' ;
8- import type { HTTPMethod , KeysEnum , MergedRequestInit } from './types' ;
7+ import type { HTTPMethod , MergedRequestInit } from './types' ;
98import { type HeadersLike } from './headers' ;
109
1110export type FinalRequestOptions = RequestOptions & { method : HTTPMethod ; path : string } ;
@@ -27,36 +26,6 @@ export type RequestOptions = {
2726 __streamClass ?: typeof Stream ;
2827} ;
2928
30- // This is required so that we can determine if a given object matches the RequestOptions
31- // type at runtime. While this requires duplication, it is enforced by the TypeScript
32- // compiler such that any missing / extraneous keys will cause an error.
33- const requestOptionsKeys : KeysEnum < RequestOptions > = {
34- method : true ,
35- path : true ,
36- query : true ,
37- body : true ,
38- headers : true ,
39-
40- maxRetries : true ,
41- stream : true ,
42- timeout : true ,
43- fetchOptions : true ,
44- signal : true ,
45- idempotencyKey : true ,
46-
47- __binaryResponse : true ,
48- __streamClass : true ,
49- } ;
50-
51- export const isRequestOptions = ( obj : unknown ) : obj is RequestOptions => {
52- return (
53- typeof obj === 'object' &&
54- obj !== null &&
55- ! isEmptyObj ( obj ) &&
56- Object . keys ( obj ) . every ( ( k ) => hasOwn ( requestOptionsKeys , k ) )
57- ) ;
58- } ;
59-
6029export type EncodedContent = { bodyHeaders : HeadersLike ; body : BodyInit } ;
6130export type RequestEncoder = ( request : { headers : NullableHeaders ; body : unknown } ) => EncodedContent ;
6231
You can’t perform that action at this time.
0 commit comments