UNPKG

nope-js-browser

Version:

NoPE Runtime for the Browser. For nodejs please use nope-js-node

46 lines (45 loc) 1.24 kB
/** * @author Martin Karkowski * @email m.karkowski@zema.de * @create date 2020-11-06 09:07:28 * @modify date 2020-11-06 09:09:33 * @desc [description] */ /** * A Custom Implementation of Nope-Promise. * They are cancelable. * * @export * @class NopePromise * @extends {Promise<T>} * @implements {INopePromise<T>} * @template T Type of the Default Promise * @template E Type of the Cancelation Data. */ export class NopePromise extends Promise { /** * Function used to cancel the Element. * * @param {E} reason * @memberof NopePromise */ cancel(reason) { throw new Error("Method has to be overwritten"); } /** * Creates an instance of NopePromise. * @param {((resolve: (value?: T | PromiseLike<T>) => void, reject: (reason?: any) => void) => void)} executor * @param {(reason: E) => void} [cancel] * @param {string} [taskId] * @memberof NopePromise */ constructor(executor, cancel, taskId) { super(executor); if (typeof cancel === "function") { this.cancel = cancel; } if (typeof taskId === "string") { this.taskId = taskId; } } }