4 ms·
Promise is the best thing an async library method could return because it's always trivial to convert into anything you want (callback, stream, async/await, yie
by esailija 12y ago
Promise is the best thing an async library method could return because it's always trivial to convert into anything you want (callback, stream, async/await, yield whatever you want) because it's the only thing that's standardized. However, nobody gets the callback contract (https://gist.github.com/CrabDude/10907185 https://gist.github.com/CrabDude/10907185) right. Even node core gets the callback contract wrong in different ways in its different APIs.
In practice however most library callback apis resemble the callback contract enough so that one-line promise-wrapping of the entire library is possible.