ziron-client
Version:
1 lines • 525 B
JavaScript
;Object.defineProperty(exports,"__esModule",{value:!0}),exports.CancellationError=void 0,exports.toCancelablePromise=toCancelablePromise;class CancellationError extends Error{constructor(e="The promise was cancelled."){super(e)}}function toCancelablePromise(e,r){let o,c=!1;const n=new Promise((r,n)=>{e.then(e=>{c=!0,r(e)}).catch(e=>{c=!0,n(e)}),o=n});return n.canceled=!1,n.cancel=(e=new CancellationError)=>c||n.canceled?n.canceled:!!r(e)&&(n.canceled=!0,o(e),!0),n}exports.CancellationError=CancellationError;