deno.land / x / ky@v0.31.3 / source / core / constants.ts

نووسراو ببینە
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import type {Expect, Equal} from '@type-challenges/utils';import {HttpMethod} from '../types/options.js';
export const supportsStreams = (() => { let duplexAccessed = false; let hasContentType = false; const supportsReadableStream = typeof globalThis.ReadableStream === 'function';
if (supportsReadableStream) { hasContentType = new globalThis.Request('https://a.com', { body: new globalThis.ReadableStream(), method: 'POST', // @ts-expect-error - Types are outdated. get duplex() { duplexAccessed = true; return 'half'; }, }).headers.has('Content-Type'); }
return duplexAccessed && !hasContentType;})();
export const supportsAbortController = typeof globalThis.AbortController === 'function';export const supportsFormData = typeof globalThis.FormData === 'function';
export const requestMethods = ['get', 'post', 'put', 'patch', 'head', 'delete'] as const;
const validate = <T extends Array<true>>() => undefined as unknown as T;validate<[ Expect<Equal<typeof requestMethods[number], HttpMethod>>,]>();
export const responseTypes = { json: 'application/json', text: 'text/*', formData: 'multipart/form-data', arrayBuffer: '*/*', blob: '*/*',} as const;
// The maximum value of a 32bit int (see issue #117)export const maxSafeTimeout = 2_147_483_647;
export const stop = Symbol('stop');
ky

Version Info

Tagged at
a year ago