cloudflare/cloudflare-typescript

Public

mirrored fromhttps://github.com/cloudflare/cloudflare-typescriptAvailable

CodeCommitsIssuesPull requestsActionsInsightsSecurity
generated-49ad31a149

Branches

Tags

  • No tags available.
0Branches0Tags
Go to file
Add file
Code

Clone

HTTPS

Download ZIP

src/_shims/index-deno.ts

110lines · modecode

1import { MultipartBody } from './MultipartBody';
2import { type RequestOptions } from '../core';
3
4export const kind: string = 'web';
5
6export type Agent = any;
7
8const _fetch = fetch;
9type _fetch = typeof fetch;
10export { _fetch as fetch };
11
12const _Request = Request;
13type _Request = Request;
14export { _Request as Request };
15
16type _RequestInfo = RequestInfo;
17export { type _RequestInfo as RequestInfo };
18
19type _RequestInit = RequestInit;
20export { type _RequestInit as RequestInit };
21
22const _Response = Response;
23type _Response = Response;
24export { _Response as Response };
25
26type _ResponseInit = ResponseInit;
27export { type _ResponseInit as ResponseInit };
28
29type _ResponseType = ResponseType;
30export { type _ResponseType as ResponseType };
31
32type _BodyInit = BodyInit;
33export { type _BodyInit as BodyInit };
34
35const _Headers = Headers;
36type _Headers = Headers;
37export { _Headers as Headers };
38
39type _HeadersInit = HeadersInit;
40export { type _HeadersInit as HeadersInit };
41
42type EndingType = 'native' | 'transparent';
43
44export interface BlobPropertyBag {
45 endings?: EndingType;
46 type?: string;
47}
48
49export interface FilePropertyBag extends BlobPropertyBag {
50 lastModified?: number;
51}
52
53export type FileFromPathOptions = Omit<FilePropertyBag, 'lastModified'>;
54
55const _FormData = FormData;
56type _FormData = FormData;
57export { _FormData as FormData };
58
59const _File = File;
60type _File = File;
61export { _File as File };
62
63const _Blob = Blob;
64type _Blob = Blob;
65export { _Blob as Blob };
66
67export async function getMultipartRequestOptions<T = Record<string, unknown>>(
68 form: FormData,
69 opts: RequestOptions<T>,
70): Promise<RequestOptions<T>> {
71 return {
72 ...opts,
73 body: new MultipartBody(form) as any,
74 };
75}
76
77export function getDefaultAgent(url: string) {
78 return undefined;
79}
80export function fileFromPath() {
81 throw new Error(
82 'The `fileFromPath` function is only supported in Node. See the README for more details: https://www.github.com/cloudflare/cloudflare-typescript#file-uploads',
83 );
84}
85
86export const isFsReadStream = (value: any) => false;
87
88export declare class Readable {
89 readable: boolean;
90 readonly readableEnded: boolean;
91 readonly readableFlowing: boolean | null;
92 readonly readableHighWaterMark: number;
93 readonly readableLength: number;
94 readonly readableObjectMode: boolean;
95 destroyed: boolean;
96 read(size?: number): any;
97 pause(): this;
98 resume(): this;
99 isPaused(): boolean;
100 destroy(error?: Error): this;
101 [Symbol.asyncIterator](): AsyncIterableIterator<any>;
102}
103
104export declare class FsReadStream extends Readable {
105 path: {}; // node type is string | Buffer
106}
107
108const _ReadableStream = ReadableStream;
109type _ReadableStream = ReadableStream;
110export { _ReadableStream as ReadableStream };
111