opnet 1.3.6 → 1.3.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.
@@ -1 +1 @@
1
- export declare const version = "1.3.5";
1
+ export declare const version = "1.3.8";
package/build/_version.js CHANGED
@@ -1 +1 @@
1
- export const version = '1.3.5';
1
+ export const version = '1.3.8';
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "opnet",
3
3
  "type": "module",
4
- "version": "1.3.6",
4
+ "version": "1.3.8",
5
5
  "author": "OP_NET",
6
6
  "description": "The perfect library for building Bitcoin-based applications.",
7
7
  "engines": {
package/src/_version.ts CHANGED
@@ -1 +1 @@
1
- export const version = '1.3.5';
1
+ export const version = '1.3.8';
@@ -1,15 +1,22 @@
1
+ // Save a reference to the original fetch
2
+ const originalFetch =
3
+ typeof fetch === 'function'
4
+ ? fetch
5
+ : typeof window !== 'undefined' && typeof window.fetch === 'function'
6
+ ? window.fetch
7
+ : typeof self !== 'undefined' && typeof self.fetch === 'function'
8
+ ? self.fetch
9
+ : undefined;
10
+
11
+ if (!originalFetch) {
12
+ throw new Error('Fetch API is not available.');
13
+ }
14
+
1
15
  const def = {
2
16
  fetch(input, init) {
3
- if (window) {
4
- return window.fetch(input, init);
5
- } else if (fetch) {
6
- return fetch(input, init);
7
- } else if (self) {
8
- return self.fetch(input, init);
9
- }
17
+ return originalFetch(input, init);
10
18
  },
11
19
  };
12
20
 
13
21
  export default def;
14
-
15
22
  export const fetch = def.fetch;