fetchache 0.1.3 → 0.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.d.ts CHANGED
@@ -3,7 +3,7 @@ export interface FetchacheCacheEntry {
3
3
  policy: CachePolicy.CachePolicyObject;
4
4
  body: string;
5
5
  }
6
- declare type FetchFn = WindowOrWorkerGlobalScope['fetch'];
6
+ declare type FetchFn = (input: URL | RequestInfo, init: RequestInit, ...rest: any[]) => Promise<Response>;
7
7
  export interface FetchacheOptions {
8
8
  fetch: FetchFn;
9
9
  Request: typeof Request;
package/index.js CHANGED
@@ -7,7 +7,7 @@ function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'defau
7
7
  const CachePolicy = _interopDefault(require('http-cache-semantics'));
8
8
 
9
9
  function fetchFactory({ fetch, Response, cache }) {
10
- return async (input, init) => {
10
+ return async (input, init, ...rest) => {
11
11
  let url;
12
12
  let method = 'GET';
13
13
  let headers = {};
@@ -27,7 +27,7 @@ function fetchFactory({ fetch, Response, cache }) {
27
27
  const entry = await cache.get(cacheKey);
28
28
  const policyRequest = policyRequestFrom(url, method, headers);
29
29
  if (!entry) {
30
- const response = await fetch(input, init);
30
+ const response = await fetch(input, init, ...rest);
31
31
  const policy = new CachePolicy(policyRequest, policyResponseFrom(response));
32
32
  return storeResponseAndReturnClone(cache, response, policy, cacheKey);
33
33
  }
@@ -52,8 +52,8 @@ function fetchFactory({ fetch, Response, cache }) {
52
52
  headers: {
53
53
  ...headers,
54
54
  ...revalidationHeaders,
55
- }
56
- });
55
+ },
56
+ }, ...rest);
57
57
  const revalidationPolicyRequest = policyRequestFrom(url, method, revalidationHeaders);
58
58
  const { policy: revalidatedPolicy, modified } = policy.revalidatedPolicy(revalidationPolicyRequest, policyResponseFrom(revalidationResponse));
59
59
  const newArrayBuffer = await revalidationResponse.arrayBuffer();
package/index.mjs CHANGED
@@ -1,7 +1,7 @@
1
1
  import CachePolicy from 'http-cache-semantics';
2
2
 
3
3
  function fetchFactory({ fetch, Response, cache }) {
4
- return async (input, init) => {
4
+ return async (input, init, ...rest) => {
5
5
  let url;
6
6
  let method = 'GET';
7
7
  let headers = {};
@@ -21,7 +21,7 @@ function fetchFactory({ fetch, Response, cache }) {
21
21
  const entry = await cache.get(cacheKey);
22
22
  const policyRequest = policyRequestFrom(url, method, headers);
23
23
  if (!entry) {
24
- const response = await fetch(input, init);
24
+ const response = await fetch(input, init, ...rest);
25
25
  const policy = new CachePolicy(policyRequest, policyResponseFrom(response));
26
26
  return storeResponseAndReturnClone(cache, response, policy, cacheKey);
27
27
  }
@@ -46,8 +46,8 @@ function fetchFactory({ fetch, Response, cache }) {
46
46
  headers: {
47
47
  ...headers,
48
48
  ...revalidationHeaders,
49
- }
50
- });
49
+ },
50
+ }, ...rest);
51
51
  const revalidationPolicyRequest = policyRequestFrom(url, method, revalidationHeaders);
52
52
  const { policy: revalidatedPolicy, modified } = policy.revalidatedPolicy(revalidationPolicyRequest, policyResponseFrom(revalidationResponse));
53
53
  const newArrayBuffer = await revalidationResponse.arrayBuffer();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fetchache",
3
- "version": "0.1.3",
3
+ "version": "0.1.4",
4
4
  "description": "Cross Platform Fetch Wrapper with Key Value Cache support",
5
5
  "sideEffects": false,
6
6
  "dependencies": {