UNPKG

scryfall-client

Version:
33 lines (32 loc) 859 B
var Task = /** @class */ (function () { function Task(fn) { var _this = this; this.taskFn = fn; this.pendingPromise = new Promise(function (resolve, reject) { _this.resolve = resolve; _this.reject = reject; }); } Task.prototype.getPromise = function () { return this.pendingPromise; }; Task.prototype.start = function () { var _this = this; return Promise.resolve() .then(function () { return _this.taskFn(); }) .then(function (result) { if (_this.resolve) { _this.resolve(result); } }) .catch(function (err) { if (_this.reject) { _this.reject(err); } }); }; return Task; }()); export default Task;