IonicaBizau/image-to-ascii

Promise support

Richienb opened this issue · 4 comments

It would be nice if image-to-ascii supported returning promises.

rmlzy commented
  async _convert(imgPath) {
    return new Promise((resolve, reject) => {
      imageToAscii(imgPath, { colored: false }, (err, converted) => {
        if (err) {
          reject(err);
          return;
        }
        resolve(converted);
      });
    });
  }

You can wrap it yourself

@rmlzy Or I could use pify:

const pify = require("pify")
const imageToAscii = pify(require("image-to-ascii"))
rmlzy commented

@Richienb Nice!

You can use util.promisify for now. Maybe in a future version Promises will be added. Contributions are welcome.