This repository has been archived by the owner on Jun 6, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 89
/
index.d.ts
88 lines (69 loc) · 2.49 KB
/
index.d.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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
/// <reference lib="webworker" />
/// <reference types="node" />
import * as http from 'http'
export = Cloudworker
declare interface CloudworkerInit {
debug?: boolean
enableCache?: boolean
bindings?: { [key: string]: any }
}
declare class Cloudworker {
constructor (script: string, opts?: CloudworkerInit)
dispatch (request: Request): Promise<Response>
listen (...args: any[]): http.Server
}
type ValidType = 'text' | 'json' | 'arrayBuffer' | 'stream'
declare class KeyValueStore {
constructor ()
get (key: string, type?: ValidType): Promise<string | ArrayBuffer | Object | ReadableStream>
put (key: string, value: string | ReadableStream | ArrayBuffer | FormData): Promise<undefined>
delete (key: string): Promise<undefined>
}
declare namespace Cloudworker {
export function fetch (input: RequestInfo, init?: RequestInit): Promise<Response>
export const FetchEvent: {
prototype: FetchEvent
new(type: string, eventInitDict: FetchEventInit): FetchEvent,
}
export const URL: {
prototype: URL;
new(url: string, base?: string | URL): URL
}
export const Headers: {
prototype: Headers
new(init?: HeadersInit): Headers,
}
type RequestInfo = Request | string | URL
export const Request: {
prototype: Request
new(input: RequestInfo, init?: RequestInit): Request,
}
export const Response: {
prototype: Response
new(body?: BodyInit | null, init?: ResponseInit): Response
redirect (url: string, status?: number): Response,
}
export const ReadableStream: {
prototype: ReadableStream
new(underlyingSource: UnderlyingByteSource, strategy?: { highWaterMark?: number, size?: undefined }): ReadableStream<Uint8Array>
new<R = any>(underlyingSource?: UnderlyingSource<R>, strategy?: QueuingStrategy<R>): ReadableStream<R>,
}
export const WritableStream: {
prototype: WritableStream
new<W = any>(underlyingSink?: UnderlyingSink<W>, strategy?: QueuingStrategy<W>): WritableStream<W>,
}
export const TransformStream: {
prototype: TransformStream
new<I = any, O = any>(transformer?: Transformer<I, O>, writableStrategy?: QueuingStrategy<I>, readableStrategy?: QueuingStrategy<O>): TransformStream<I, O>,
}
export const TextEncoder: {
prototype: TextEncoder
new(): TextEncoder,
}
export const TextDecoder: {
prototype: TextDecoder
new(label?: string, options?: TextDecoderOptions): TextDecoder,
}
export function atob (encodedString: string): string
export function btoa (rawString: string): string
}