@cacheable/net 2.0.7 → 2.0.8

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/dist/index.cjs CHANGED
@@ -45,21 +45,21 @@ var import_hookified = require("hookified");
45
45
 
46
46
  // src/fetch.ts
47
47
  var import_http_cache_semantics = __toESM(require("http-cache-semantics"), 1);
48
- var import_undici = require("undici");
48
+ var runtimeFetch = globalThis.fetch.bind(globalThis);
49
49
  async function fetch(url, options) {
50
50
  const fetchOptions = {
51
51
  ...options,
52
52
  cache: "no-cache"
53
53
  };
54
54
  if (!options.cache) {
55
- const response2 = await (0, import_undici.fetch)(url, fetchOptions);
55
+ const response2 = await runtimeFetch(url, fetchOptions);
56
56
  if (!response2.ok) {
57
57
  throw new Error(`Fetch failed with status ${response2.status}`);
58
58
  }
59
59
  return response2;
60
60
  }
61
61
  if (options.method === "POST" || options.method === "PATCH" || options.method === "DELETE" || options.method === "HEAD") {
62
- const response2 = await (0, import_undici.fetch)(url, fetchOptions);
62
+ const response2 = await runtimeFetch(url, fetchOptions);
63
63
  if (!response2.ok) {
64
64
  throw new Error(`Fetch failed with status ${response2.status}`);
65
65
  }
@@ -70,7 +70,7 @@ async function fetch(url, options) {
70
70
  const cacheKey = `${method}:${url}`;
71
71
  if (!httpCachePolicy) {
72
72
  const cachedData = await options.cache.getOrSet(cacheKey, async () => {
73
- const response2 = await (0, import_undici.fetch)(url, fetchOptions);
73
+ const response2 = await runtimeFetch(url, fetchOptions);
74
74
  if (!response2.ok) {
75
75
  throw new Error(`Fetch failed with status ${response2.status}`);
76
76
  }
@@ -128,7 +128,7 @@ async function fetch(url, options) {
128
128
  if (policy?.revalidationHeaders(request)) {
129
129
  revalidationHeaders = policy.revalidationHeaders(request);
130
130
  }
131
- const response = await (0, import_undici.fetch)(url, {
131
+ const response = await runtimeFetch(url, {
132
132
  ...fetchOptions,
133
133
  headers: {
134
134
  ...fetchOptions.headers,
package/dist/index.js CHANGED
@@ -4,23 +4,21 @@ import { Hookified } from "hookified";
4
4
 
5
5
  // src/fetch.ts
6
6
  import CachePolicy from "http-cache-semantics";
7
- import {
8
- fetch as undiciFetch
9
- } from "undici";
7
+ var runtimeFetch = globalThis.fetch.bind(globalThis);
10
8
  async function fetch(url, options) {
11
9
  const fetchOptions = {
12
10
  ...options,
13
11
  cache: "no-cache"
14
12
  };
15
13
  if (!options.cache) {
16
- const response2 = await undiciFetch(url, fetchOptions);
14
+ const response2 = await runtimeFetch(url, fetchOptions);
17
15
  if (!response2.ok) {
18
16
  throw new Error(`Fetch failed with status ${response2.status}`);
19
17
  }
20
18
  return response2;
21
19
  }
22
20
  if (options.method === "POST" || options.method === "PATCH" || options.method === "DELETE" || options.method === "HEAD") {
23
- const response2 = await undiciFetch(url, fetchOptions);
21
+ const response2 = await runtimeFetch(url, fetchOptions);
24
22
  if (!response2.ok) {
25
23
  throw new Error(`Fetch failed with status ${response2.status}`);
26
24
  }
@@ -31,7 +29,7 @@ async function fetch(url, options) {
31
29
  const cacheKey = `${method}:${url}`;
32
30
  if (!httpCachePolicy) {
33
31
  const cachedData = await options.cache.getOrSet(cacheKey, async () => {
34
- const response2 = await undiciFetch(url, fetchOptions);
32
+ const response2 = await runtimeFetch(url, fetchOptions);
35
33
  if (!response2.ok) {
36
34
  throw new Error(`Fetch failed with status ${response2.status}`);
37
35
  }
@@ -89,7 +87,7 @@ async function fetch(url, options) {
89
87
  if (policy?.revalidationHeaders(request)) {
90
88
  revalidationHeaders = policy.revalidationHeaders(request);
91
89
  }
92
- const response = await undiciFetch(url, {
90
+ const response = await runtimeFetch(url, {
93
91
  ...fetchOptions,
94
92
  headers: {
95
93
  ...fetchOptions.headers,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cacheable/net",
3
- "version": "2.0.7",
3
+ "version": "2.0.8",
4
4
  "description": "High Performance Network Caching for Node.js with fetch, request, http 1.1, and http 2 support",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -35,7 +35,7 @@
35
35
  "hookified": "^1.15.1",
36
36
  "http-cache-semantics": "^4.2.0",
37
37
  "undici": "^7.24.5",
38
- "cacheable": "^2.3.4"
38
+ "cacheable": "^2.3.5"
39
39
  },
40
40
  "keywords": [
41
41
  "cacheable",