UNPKG

@ablestack/deferred-promise-ts

Version:

A tiny library, containing a strongly typed deferred-promise class, that leverages ES6 promises and implements the Promise<T> interface

28 lines 800 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.DeferredPromise = void 0; class DeferredPromise { constructor() { this.promise = new Promise((resolve, reject) => { this._resolveSelf = resolve; this._rejectSelf = reject; }); } then(onfulfilled, onrejected) { return this.promise.then(onfulfilled, onrejected); } catch(onrejected) { return this.promise.then(onrejected); } finally(onfinally) { return this.promise.finally(onfinally); } resolve(val) { this._resolveSelf(val); } reject(reason) { this._rejectSelf(reason); } } exports.DeferredPromise = DeferredPromise; //# sourceMappingURL=DeferredPromise.js.map