UNPKG

2.95 kBTypeScriptView Raw
1/*
2 * Copyright 2021 Adobe. All rights reserved.
3 * This file is licensed to you under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License. You may obtain a copy
5 * of the License at http://www.apache.org/licenses/LICENSE-2.0
6 *
7 * Unless required by applicable law or agreed to in writing, software distributed under
8 * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
9 * OF ANY KIND, either express or implied. See the License for the specific language
10 * governing permissions and limitations under the License.
11 */
12
13export * from './api';
14import * as api from './api.d';
15import { ContextOptions } from './api';
16
17declare type FetchAPI = typeof api;
18
19/**
20 * This function returns an object which looks like the public API,
21 * i.e. it will have the functions `fetch`, `context`, `reset`, etc. and provide its
22 * own isolated caches and specific behavior according to `options`.
23 *
24 * @param {ContextOptions} options
25 */
26export declare function context(options?: ContextOptions): FetchAPI;
27
28/**
29 * Convenience function which creates a new context with disabled caching,
30 * the equivalent of `context({ maxCacheSize: 0 })`.
31 *
32 * The optional `options` parameter allows to specify further options.
33 *
34 * @param {ContextOptions} options
35 */
36export declare function noCache(options?: ContextOptions): FetchAPI;
37
38 /**
39 * Convenience function which creates a new context with enforced HTTP/1.1 protocol,
40 * the equivalent of `context({ alpnProtocols: [ALPN_HTTP1_1] })`.
41 *
42 * The optional `options` parameter allows to specify further options.
43 *
44 * @param {ContextOptions} options
45 */
46 export declare function h1(options?: ContextOptions): FetchAPI;
47
48 /**
49 * Convenience function which creates a new context with enforced HTTP/1.1 protocol
50 * with persistent connections (keep-alive), the equivalent of
51 * `context({ alpnProtocols: [ALPN_HTTP1_1], h1: { keepAlive: true } })`.
52 *
53 * The optional `options` parameter allows to specify further options.
54 *
55 * @param {ContextOptions} options
56 */
57 export declare function keepAlive(options?: ContextOptions): FetchAPI;
58
59 /**
60 * Convenience function which creates a new context with disabled caching
61 * and enforced HTTP/1.1 protocol, a combination of `h1()` and `noCache()`.
62 *
63 * The optional `options` parameter allows to specify further options.
64 *
65 * @param {ContextOptions} options
66 */
67 export declare function h1NoCache(options?: ContextOptions): FetchAPI;
68
69 /**
70 * Convenience function which creates a new context with disabled caching
71 * and enforced HTTP/1.1 protocol with persistent connections (keep-alive),
72 * a combination of `keepAlive()` and `noCache()`.
73 *
74 * The optional `options` parameter allows to specify further options.
75 *
76 * @param {ContextOptions} options
77 */
78 export declare function keepAliveNoCache(options?: ContextOptions): FetchAPI;
79
\No newline at end of file