-
Notifications
You must be signed in to change notification settings - Fork 18
/
index.d.ts
54 lines (49 loc) · 2.21 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
/**
* Utility that provides a single API for loading the content of a path/URL.
*/
declare module 'path-loader' {
/**
* Loads a document at the provided location and returns a JavaScript object representation.
* @param location - The location to the document
* @param options - The loader options
* @returns Always returns a promise even if there is a callback provided
*/
export function load(location: string, options?: module:path-loader.LoadOptions): Promise<any>;
/**
* Options used when loading a path.
*/
interface LoadOptions {
/**
* The encoding to use when loading the file *(File loader only)*
*/
encoding?: string;
/**
* The HTTP method to use for the request *(HTTP loader only)*
*/
method?: string;
/**
* The callback used to prepare the request *(HTTP loader only)*
*/
prepareRequest?: module:path-loader.PrepareRequestCallback;
/**
* The callback used to process the response
*/
processContent?: module:path-loader.ProcessResponseCallback;
}
/**
* Callback used to provide access to altering a remote request prior to the request being made.
* @param req - The Superagent request object
* @param location - The location being retrieved
* @param callback - First callback
*/
export type PrepareRequestCallback = (req: object, location: string, callback: Function)=>void;
/**
* Callback used to provide access to processing the raw response of the request being made. *(HTTP loader only)*
* @param res - The Superagent response object *(For non-HTTP loaders, this object will be like the Superagent
* object in that it will have a `text` property whose value is the raw string value being processed. This was done
* for consistency. There will also be a `location` property containing the location of the path being loaded.)*
* @param callback - Error-first callback
* @returns the result of processing the responses
*/
export type ProcessResponseCallback = (res: object, callback: Function)=>any;
}