Browse Source

Merge pull request #296 from tmcw/thenable-then

Make then .then(resolve, reject) API thenable. Fixes #295

Merged, thanks for contribution 👍
pull/307/head
jeromewu 6 years ago committed by GitHub
parent
commit
5cd2c083eb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 16
      src/common/TesseractJob.js

16
src/common/TesseractJob.js

@ -48,14 +48,14 @@ class TesseractJob {
* @param {function} reject - called when the job fails * @param {function} reject - called when the job fails
*/ */
then(resolve, reject) { then(resolve, reject) {
if (this._resolve.push) { return new Promise((res, rej) => {
this._resolve.push(resolve); if (!this._resolve.push) {
} else { res(this._result);
resolve(this._resolve); } else {
} this._resolve.push(res);
}
if (reject) this.catch(reject); this.catch(rej);
return this; }).then(resolve, reject);
} }
/** /**

Loading…
Cancel
Save