@adyen/adyen-platform-experience-web
Version:

28 lines (27 loc) • 839 B
JavaScript
import { struct as d } from "../../../utils/struct/main.js";
import { getter as s, enumerable as n } from "../../../utils/struct/property.js";
import { isUndefined as b } from "../../../utils/value/is.js";
import { noop as u } from "../../../utils/common.js";
const w = (o) => {
let r, t, e;
const l = () => {
if (b(r)) return;
const i = r.abort.bind(r);
r = void 0, i();
}, m = () => (e = new Promise((i, c) => {
if (t.addEventListener("abort", function _() {
t.removeEventListener("abort", _), c(o);
}), t.aborted) throw o;
}), e.catch(u), e), a = () => (b(r) && (r = new AbortController(), t = r.signal, e = m()), f), f = d({
abort: n(l),
promise: s(() => e),
reason: n(o),
refresh: n(a),
signal: s(() => t)
});
return a();
};
export {
w as createAbortable,
w as default
};