Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
MR414N-ID
GitHub Repository: MR414N-ID/botku2
Path: blob/master/node_modules/@protobufjs/fetch/index.d.ts
1126 views
1
export = fetch;
2
3
/**
4
* Node-style callback as used by {@link util.fetch}.
5
* @typedef FetchCallback
6
* @type {function}
7
* @param {?Error} error Error, if any, otherwise `null`
8
* @param {string} [contents] File contents, if there hasn't been an error
9
* @returns {undefined}
10
*/
11
type FetchCallback = (error: Error, contents?: string) => void;
12
13
/**
14
* Options as used by {@link util.fetch}.
15
* @typedef FetchOptions
16
* @type {Object}
17
* @property {boolean} [binary=false] Whether expecting a binary response
18
* @property {boolean} [xhr=false] If `true`, forces the use of XMLHttpRequest
19
*/
20
21
interface FetchOptions {
22
binary?: boolean;
23
xhr?: boolean
24
}
25
26
/**
27
* Fetches the contents of a file.
28
* @memberof util
29
* @param {string} filename File path or url
30
* @param {FetchOptions} options Fetch options
31
* @param {FetchCallback} callback Callback function
32
* @returns {undefined}
33
*/
34
declare function fetch(filename: string, options: FetchOptions, callback: FetchCallback): void;
35
36
/**
37
* Fetches the contents of a file.
38
* @name util.fetch
39
* @function
40
* @param {string} path File path or url
41
* @param {FetchCallback} callback Callback function
42
* @returns {undefined}
43
* @variation 2
44
*/
45
declare function fetch(path: string, callback: FetchCallback): void;
46
47
/**
48
* Fetches the contents of a file.
49
* @name util.fetch
50
* @function
51
* @param {string} path File path or url
52
* @param {FetchOptions} [options] Fetch options
53
* @returns {Promise<string|Uint8Array>} Promise
54
* @variation 3
55
*/
56
declare function fetch(path: string, options?: FetchOptions): Promise<(string|Uint8Array)>;
57
58