Hacker News new | past | comments | ask | show | jobs | submit login

Why the promise-like interface? If it returned a promise with a this-returning progress method monkey-patched onto it, then you could use it otherwise like a regular promise:

    Tesseract.recognize(myImage)
      .progress(function(message){console.log(message)})
      .then(function(result){console.log(result)})
      .catch(function(err){console.error(err)});
or

    Tesseract.recognize(myImage)
      .progress(function(message){console.log(message)})
      .then(
        function(result){console.log(result)},
        function(err){console.error(err)}
      );
I guess I just still have bad memories of jQuery's old almost-like-real promises. I'd rather never have to think ever again about whether I'm dealing with a real promise or one that's going to surprise me and break at run-time because I tried to use it like a real one.



If you want to use a real Promise, you can wrap the call to recognize in Promise.resolve:

  Promise.resolve(Tesseract.recognize(myImage)).then(result => console.log(result))




Applications are open for YC Summer 2020

Guidelines | FAQ | Support | API | Security | Lists | Bookmarklet | Legal | Apply to YC | Contact

Search: