image-pixels icon indicating copy to clipboard operation
image-pixels copied to clipboard

Sync API

Open dy opened this issue 6 years ago • 1 comments

Sometimes that is useful to avoid async/await code: there is readFileSync, even sync request, image-decode has sync API, so the only necessity in sync is browser-based primitives, not completed Image, Blob etc.

Just wonder - how bad the practice of returning Promise along with the ready result is. That seems trivial for people who care about async API just do

Promise.resolve(pixels(src)).then(data => {})

and who needs sync fashion for everything just do as it is now:

var data = await pixels(src)

but that enables sync API as well, instead of Promises:

var data = pixels(path)

dy avatar Nov 12 '18 03:11 dy

That would allow for simple image-equal API eh...

eq('./a.js', arr)

dy avatar Nov 12 '18 03:11 dy