@fuman/fetch 0.0.11 → 0.0.13

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.
Files changed (3) hide show
  1. package/ffetch.cjs +6 -5
  2. package/ffetch.js +6 -5
  3. package/package.json +1 -1
package/ffetch.cjs CHANGED
@@ -25,8 +25,8 @@ class FfetchResultImpl {
25
25
  _options;
26
26
  _headers;
27
27
  #stack;
28
- constructor(fetch2, url, init, headers, options, stack) {
29
- this.#fetch = fetch2;
28
+ constructor(fetch, url, init, headers, options, stack) {
29
+ this.#fetch = fetch;
30
30
  this._init = init;
31
31
  this._url = url;
32
32
  this._options = options;
@@ -125,7 +125,7 @@ function _wrapMethod(method, fn) {
125
125
  }
126
126
  function createFfetch(baseOptions = {}) {
127
127
  const captureStackTrace = baseOptions.captureStackTrace ?? true;
128
- const baseFetch = baseOptions.fetch ?? fetch;
128
+ const baseFetch = baseOptions.fetch ?? globalThis.fetch?.bind(globalThis);
129
129
  const wrappedFetch = baseOptions.middlewares !== void 0 && baseOptions.middlewares.length > 0 ? utils.composeMiddlewares(baseOptions.middlewares, baseFetch) : baseFetch;
130
130
  const addons = baseOptions.addons ?? [];
131
131
  let FfetchResultInner;
@@ -194,6 +194,7 @@ function createFfetch(baseOptions = {}) {
194
194
  }
195
195
  }
196
196
  init.headers = headers;
197
+ options.validateResponse ??= baseOptions.validateResponse;
197
198
  return new FfetchResultInner(fetcher, url, init, headers, options, stack);
198
199
  };
199
200
  const fn = fn_;
@@ -218,8 +219,8 @@ function createFfetch(baseOptions = {}) {
218
219
  ...otherOptions.middlewares ?? []
219
220
  ],
220
221
  headers: {
221
- ...baseOptions.headers,
222
- ...otherOptions.headers
222
+ ...headersToObject(baseOptions.headers),
223
+ ...headersToObject(otherOptions.headers)
223
224
  }
224
225
  });
225
226
  };
package/ffetch.js CHANGED
@@ -23,8 +23,8 @@ class FfetchResultImpl {
23
23
  _options;
24
24
  _headers;
25
25
  #stack;
26
- constructor(fetch2, url, init, headers, options, stack) {
27
- this.#fetch = fetch2;
26
+ constructor(fetch, url, init, headers, options, stack) {
27
+ this.#fetch = fetch;
28
28
  this._init = init;
29
29
  this._url = url;
30
30
  this._options = options;
@@ -123,7 +123,7 @@ function _wrapMethod(method, fn) {
123
123
  }
124
124
  function createFfetch(baseOptions = {}) {
125
125
  const captureStackTrace = baseOptions.captureStackTrace ?? true;
126
- const baseFetch = baseOptions.fetch ?? fetch;
126
+ const baseFetch = baseOptions.fetch ?? globalThis.fetch?.bind(globalThis);
127
127
  const wrappedFetch = baseOptions.middlewares !== void 0 && baseOptions.middlewares.length > 0 ? composeMiddlewares(baseOptions.middlewares, baseFetch) : baseFetch;
128
128
  const addons = baseOptions.addons ?? [];
129
129
  let FfetchResultInner;
@@ -192,6 +192,7 @@ function createFfetch(baseOptions = {}) {
192
192
  }
193
193
  }
194
194
  init.headers = headers;
195
+ options.validateResponse ??= baseOptions.validateResponse;
195
196
  return new FfetchResultInner(fetcher, url, init, headers, options, stack);
196
197
  };
197
198
  const fn = fn_;
@@ -216,8 +217,8 @@ function createFfetch(baseOptions = {}) {
216
217
  ...otherOptions.middlewares ?? []
217
218
  ],
218
219
  headers: {
219
- ...baseOptions.headers,
220
- ...otherOptions.headers
220
+ ...headersToObject(baseOptions.headers),
221
+ ...headersToObject(otherOptions.headers)
221
222
  }
222
223
  });
223
224
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@fuman/fetch",
3
3
  "type": "module",
4
- "version": "0.0.11",
4
+ "version": "0.0.13",
5
5
  "description": "tiny wrapper over fetch",
6
6
  "license": "MIT",
7
7
  "dependencies": {