UNPKG

@adyen/adyen-platform-experience-web

Version:

![Platform Experience header](https://github.com/Adyen/adyen-platform-experience-web/assets/7926613/18094965-9e01-450e-8dc9-ea84e6b22c2b)

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