laif-ds
Version:
Design System di Laif con componenti React basati su principi di Atomic Design
62 lines (61 loc) • 1.27 kB
JavaScript
"use client";
function x() {
const o = [], u = { run: c, use: p };
return u;
function c(...n) {
let h = -1;
const t = n.pop();
if (typeof t != "function")
throw new TypeError("Expected function as last argument, not " + t);
f(null, ...n);
function f(e, ...i) {
const r = o[++h];
let l = -1;
if (e) {
t(e);
return;
}
for (; ++l < n.length; )
(i[l] === null || i[l] === void 0) && (i[l] = n[l]);
n = i, r ? s(r, f)(...i) : t(null, ...i);
}
}
function p(n) {
if (typeof n != "function")
throw new TypeError(
"Expected `middelware` to be a function, not " + n
);
return o.push(n), u;
}
}
function s(o, u) {
let c;
return p;
function p(...t) {
const f = o.length > t.length;
let e;
f && t.push(n);
try {
e = o.apply(this, t);
} catch (i) {
const r = (
/** @type {Error} */
i
);
if (f && c)
throw r;
return n(r);
}
f || (e && e.then && typeof e.then == "function" ? e.then(h, n) : e instanceof Error ? n(e) : h(e));
}
function n(t, ...f) {
c || (c = !0, u(t, ...f));
}
function h(t) {
n(null, t);
}
}
export {
x as trough,
s as wrap
};