@akiyamka/extended-fetch
Advanced tools
Comparing version 0.0.9 to 0.0.10
@@ -13,7 +13,7 @@ const m = "Network request timed out", p = globalThis, b = (t) => { | ||
var o; | ||
const a = l.split(":"), c = (o = a.shift()) == null ? void 0 : o.trim(); | ||
if (c) { | ||
const a = l.split(":"), d = (o = a.shift()) == null ? void 0 : o.trim(); | ||
if (d) { | ||
const e = a.join(":").trim(); | ||
try { | ||
i.append(c, e); | ||
i.append(d, e); | ||
} catch (u) { | ||
@@ -26,3 +26,3 @@ u && typeof u == "object" && "message" in u ? console.warn("Response " + u.message) : console.warn("Response " + u); | ||
const w = async (t) => t == null ? null : typeof t == "string" ? t : "getReader" in t ? await new Response(t).blob() : t, y = (t, i, n) => new Promise(async (l, a) => { | ||
const c = i == null ? void 0 : i.body, o = (() => { | ||
const d = i == null ? void 0 : i.body, o = (() => { | ||
try { | ||
@@ -43,3 +43,3 @@ return new Request(t, i); | ||
try { | ||
const r = o.url.indexOf("file://") === 0 && (e.status < 200 || e.status > 599), d = { | ||
const r = o.url.indexOf("file://") === 0 && (e.status < 200 || e.status > 599), c = { | ||
statusText: e.statusText, | ||
@@ -49,5 +49,5 @@ headers: h(e.getAllResponseHeaders() || ""), | ||
}; | ||
d.url = "responseURL" in e ? e.responseURL : d.headers.get("X-Request-URL"); | ||
c.url = "responseURL" in e ? e.responseURL : c.headers.get("X-Request-URL"); | ||
const g = "response" in e ? e.response : e.responseText; | ||
setTimeout(() => l(new Response(g, d)), 0); | ||
setTimeout(() => l(new Response(g, c)), 0); | ||
} catch (r) { | ||
@@ -76,3 +76,3 @@ console.log("CATCHED"), a(r); | ||
} | ||
const u = await w(c); | ||
const u = await w(d); | ||
e.send(u); | ||
@@ -82,5 +82,5 @@ }), E = (t) => typeof t == "object" && t !== null && "message" in t && t.message === m, R = (t) => typeof t == "object" && t !== null && "name" in t && // https://dom.spec.whatwg.org/#aborting-ongoing-activities-example | ||
export { | ||
y as fetch, | ||
y as default, | ||
R as isAbortError, | ||
E as isTimeoutError | ||
}; |
import { ExtendedFetchPreferences } from './types'; | ||
export declare const fetch: (input: RequestInfo | URL, init?: RequestInit, pref?: ExtendedFetchPreferences) => Promise<Response>; | ||
declare const _default: (input: RequestInfo | URL, init?: RequestInit, pref?: ExtendedFetchPreferences) => Promise<Response>; | ||
export default _default; | ||
export declare const isTimeoutError: (err: unknown) => boolean; | ||
export declare const isAbortError: (err: unknown) => boolean; | ||
export type { ExtendedFetchPreferences } from './types'; |
{ | ||
"name": "@akiyamka/extended-fetch", | ||
"version": "0.0.9", | ||
"version": "0.0.10", | ||
"description": "Tiny window.fetch JavaScript implementation over XMLHttpRequest with additional features", | ||
@@ -13,4 +13,4 @@ "repository": { | ||
], | ||
"types": "./dist/extended-fetch.d.ts", | ||
"main": "./dist/cjs/index.cjs", | ||
"types": "./dist/lib/extended-fetch.d.ts", | ||
"main": "./dist/extended-fetch.cjs", | ||
"module": "./dist/extended-fetch.js", | ||
@@ -17,0 +17,0 @@ "exports": { |
@@ -34,5 +34,5 @@ # extended-fetch | ||
```js | ||
import { fetch, isTimeoutError } from '@akiyamka/extended-fetch' | ||
import extendedFetch, { isTimeoutError } from '@akiyamka/extended-fetch' | ||
fetch('/users', { | ||
extendedFetch('/users', { | ||
method: 'POST', | ||
@@ -51,5 +51,5 @@ body: JSON.stringify({ foo: 'bar' }), | ||
```js | ||
import { fetch } from 'extended-fetch' | ||
import extendedFetch from 'extended-fetch' | ||
fetch( | ||
extendedFetch( | ||
'/users', | ||
@@ -78,3 +78,3 @@ // Fetch configuration | ||
```ts | ||
import { fetch, isAbortError } from 'extended-fetch' | ||
import extendedFetch, { isAbortError } from 'extended-fetch' | ||
@@ -84,3 +84,3 @@ const abortController = new AbortController() | ||
try { | ||
const reference = await fetch(srv.readyCheck(), { | ||
const reference = await extendedFetch(srv.readyCheck(), { | ||
signal: abortController.signal, | ||
@@ -87,0 +87,0 @@ }) |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
13002
125