revisitors / readimage

Read a (jpg, png, gif) image into a standard binary format in memory.
MIT License
14 stars 5 forks source link

Promise support #3

Open Richienb opened 4 years ago

Richienb commented 4 years ago

It would be useful if this library supported promises.

dotnetCarpenter commented 3 years ago

@Richienb just wrap it:

const readImage = require ("readimage")

const read = buffer => new Promise ((resolve, reject) => {
    readImage (buffer, (err, image) => {
        if (err) reject (err)
        resolve (image)
    })
}

👆 Now readimage support promises.

Richienb commented 3 years ago

Not looking for a quick workaround.

dotnetCarpenter commented 3 years ago

Personally, I would hate Promises as the only API for readimage since I loath error handling with nested Promises.

But I already created a fork, so my opinion is not important.