Comparing version 0.0.27 to 0.0.28
@@ -18,3 +18,3 @@ declare type AbortControllerGroup = { | ||
declare type Declaration<Result, E = never, A = void> = { | ||
export declare type Declaration<Result, E = never, A = void> = { | ||
fetch: PreparedFetch<Result, E, A>; | ||
@@ -24,3 +24,3 @@ key: string; | ||
declare type Declare<F extends Fetch> = <V = unknown, E = unknown, A = void>(resource: Resource, options?: FetchOptions | ((args: A) => FetchOptions)) => InferFetchResult<F> extends FetchResult ? Declaration<FetchResult<V, E>, never, A> : Declaration<V, null | E, A>; | ||
export declare type Declare<F extends Fetch> = <V = unknown, E = unknown, A = void>(resource: Resource, options?: FetchOptions | ((args: A) => FetchOptions)) => InferFetchResult<F> extends FetchResult ? Declaration<FetchResult<V, E>, never, A> : Declaration<V, null | E, A>; | ||
@@ -176,3 +176,3 @@ /** | ||
declare type PreparedFetch<V = unknown, E = unknown, A = unknown> = (args: A, options?: FetchOptions) => PromiseWithError<V, E>; | ||
export declare type PreparedFetch<V = unknown, E = unknown, A = unknown> = (args: A, options?: FetchOptions) => PromiseWithError<V, E>; | ||
@@ -179,0 +179,0 @@ /** |
@@ -1,2 +0,2 @@ | ||
const D = (e) => "File" in window && e instanceof File, H = (e) => e instanceof FormData, _ = (e) => { | ||
const C = (e) => "File" in window && e instanceof File, M = (e) => e instanceof FormData, D = (e) => { | ||
const t = new FormData(); | ||
@@ -9,5 +9,5 @@ return Object.entries(e).forEach(([n, r]) => { | ||
return t.set(n, `${r}`); | ||
if (D(r)) | ||
if (C(r)) | ||
return t.set(n, r); | ||
if (Array.isArray(r) && r.length && r.every((o) => D(o))) | ||
if (Array.isArray(r) && r.length && r.every((o) => C(o))) | ||
return r.forEach((o) => t.append(`${n}[]`, o)); | ||
@@ -24,3 +24,3 @@ if (typeof r == "object" && r !== null || Array.isArray(r)) { | ||
}), t; | ||
}, C = (e, t) => { | ||
}, _ = (e, t) => { | ||
e.addEventListener( | ||
@@ -54,4 +54,4 @@ "abort", | ||
const r = new URL(e, "https://developer.mozilla.org"), o = Object.fromEntries(r.searchParams), i = Object.fromEntries(new URLSearchParams(t)), u = n ? i : { ...o, ...i }, s = Object.entries(u).toSorted(([d], [y]) => d.localeCompare(y)), f = new URLSearchParams(s).toString(), c = f ? `?${f}` : ""; | ||
return M(e) ? `${r.origin}${r.pathname}${c}` : `${r.pathname}${c}`; | ||
}, g = (e) => (Array.isArray(e) ? e : [e]).join("/"), M = (e) => { | ||
return q(e) ? `${r.origin}${r.pathname}${c}` : `${r.pathname}${c}`; | ||
}, g = (e) => (Array.isArray(e) ? e : [e]).join("/"), q = (e) => { | ||
try { | ||
@@ -62,4 +62,4 @@ return !!new URL(e); | ||
} | ||
}, q = (e) => e == null, z = (e) => { | ||
if (q(e)) | ||
}, z = (e) => e == null, B = (e) => { | ||
if (z(e)) | ||
throw new Error("Non-nullable assertion failed"); | ||
@@ -77,3 +77,3 @@ return e; | ||
log: () => void console.log(e), | ||
notNullable: () => z(e) | ||
notNullable: () => B(e) | ||
}), m = Object.assign(L, { | ||
@@ -100,3 +100,3 @@ Ok: L, | ||
} | ||
}), B = (e) => { | ||
}), V = (e) => { | ||
try { | ||
@@ -107,3 +107,3 @@ return m.Ok(e()); | ||
} | ||
}, j = (e) => e instanceof Error, Q = async (e, t) => { | ||
}, j = (e) => e instanceof Error, W = async (e, t) => { | ||
const { | ||
@@ -124,3 +124,3 @@ strict: n = !0, | ||
timeout: S, | ||
unwrap: K, | ||
unwrap: Q, | ||
...l | ||
@@ -147,5 +147,5 @@ } = t ?? {}; | ||
} | ||
if (l.signal && C(l.signal, h), l.signal = h.signal, u) { | ||
if (l.signal && _(l.signal, h), l.signal = h.signal, u) { | ||
const a = u.add(); | ||
C(a.signal, h); | ||
_(a.signal, h); | ||
} | ||
@@ -158,3 +158,3 @@ const N = typeof S == "number" ? setTimeout(() => h.abort(U), S) : null; | ||
throw new Error("Fetch provided multiple values for body. Pick data, files or form."); | ||
d && (l.body = H(d) ? d : _(d)), E && (l.body = _(E)); | ||
d && (l.body = M(d) ? d : D(d)), E && (l.body = D(E)); | ||
} | ||
@@ -165,4 +165,4 @@ const G = J(e, y ?? {}); | ||
N && clearTimeout(N); | ||
const O = a.headers.get("content-type"), k = O == null ? void 0 : O.includes("application/json"); | ||
if (n && !k) | ||
const O = a.headers.get("content-type"), k = O == null ? void 0 : O.includes("application/json"), H = a.status === 204; | ||
if (n && !H && !k) | ||
return R({ | ||
@@ -175,3 +175,3 @@ response: a, | ||
if (F) | ||
return V({ | ||
return X({ | ||
value: A, | ||
@@ -205,3 +205,3 @@ response: a | ||
} | ||
}, V = (e) => Object.assign(m.Ok(e.value), { | ||
}, X = (e) => Object.assign(m.Ok(e.value), { | ||
aborted: !1, | ||
@@ -224,3 +224,3 @@ timeout: !1, | ||
}); | ||
}, U = Symbol("Timeout"), W = async (e, t) => (console.log( | ||
}, U = Symbol("Timeout"), Y = async (e, t) => (console.log( | ||
"%c🐕 " + ((t == null ? void 0 : t.method) || "GET").toUpperCase(), | ||
@@ -234,3 +234,3 @@ "background: #85ce47; border-radius: 999px; font-weight: 600; padding: 1.5px 5.5px; color: black", | ||
response: new Response() | ||
})), Y = async (e, t) => Object.assign(m.Ok({}), { | ||
})), Z = async (e, t) => Object.assign(m.Ok({}), { | ||
aborted: !1, | ||
@@ -253,10 +253,10 @@ timeout: !1, | ||
}); | ||
}, X = (e, t) => P(e, (n) => (r, o) => { | ||
}, v = (e, t) => P(e, (n) => (r, o) => { | ||
const i = typeof t == "function" ? t(o) : t; | ||
return n(r, x(o, i)); | ||
}), v = (e, t) => P(e, (n) => (r, o) => (r = g(r), n( | ||
}), I = (e, t) => P(e, (n) => (r, o) => (r = g(r), n( | ||
typeof t == "function" ? t(r) : r + g(t), | ||
o | ||
))), Z = (e, t) => v(e, (n) => t + n), ee = (e) => { | ||
const t = (n) => X(e, { method: n }); | ||
))), ee = (e, t) => I(e, (n) => t + n), te = (e) => { | ||
const t = (n) => v(e, { method: n }); | ||
return { | ||
@@ -272,9 +272,9 @@ method: t, | ||
}; | ||
}, te = (e) => (t, n) => { | ||
}, re = (e) => (t, n) => { | ||
t = g(t); | ||
const r = I(t, typeof n == "function" ? {} : n); | ||
const r = K(t, typeof n == "function" ? {} : n); | ||
return { | ||
key: r, | ||
fetch: (i, u) => { | ||
const s = B( | ||
const s = V( | ||
() => typeof n == "function" ? n(i) : n | ||
@@ -289,3 +289,3 @@ ); | ||
}; | ||
}, I = (e, t) => J(e, (t == null ? void 0 : t.params) ?? {}), re = () => { | ||
}, K = (e, t) => J(e, (t == null ? void 0 : t.params) ?? {}), ne = () => { | ||
const e = /* @__PURE__ */ new Set(); | ||
@@ -302,3 +302,3 @@ return { | ||
}; | ||
}, ne = (e) => (t, n) => e(t, n).then((r) => r.unwrap()); | ||
}, oe = (e) => (t, n) => e(t, n).then((r) => r.unwrap()); | ||
export { | ||
@@ -308,17 +308,17 @@ R as Except, | ||
m as Result, | ||
re as createAbortGroup, | ||
W as debugFetch, | ||
Q as fetch, | ||
ne as createAbortGroup, | ||
Y as debugFetch, | ||
W as fetch, | ||
x as mergeOptions, | ||
J as params, | ||
J as respectParams, | ||
Q as resultFetch, | ||
ne as unwrap, | ||
Y as voidFetch, | ||
Z as withBase, | ||
te as withDeclarations, | ||
W as resultFetch, | ||
oe as unwrap, | ||
Z as voidFetch, | ||
ee as withBase, | ||
re as withDeclarations, | ||
P as withFetch, | ||
ee as withMethods, | ||
X as withOptions, | ||
v as withResource | ||
te as withMethods, | ||
v as withOptions, | ||
I as withResource | ||
}; |
{ | ||
"name": "adnf", | ||
"version": "0.0.27", | ||
"version": "0.0.28", | ||
"type": "module", | ||
@@ -5,0 +5,0 @@ "files": [ |
Sorry, the diff of this file is not supported yet
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
42733