This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Here is a function that I use all the time when creating public | |
// async APIs in JavaScript: | |
const resolvePromise = (promise, callback) => { | |
if (callback) | |
promise.then(value => callback(null, value), callback) | |
return promise | |
} | |
// Sometimes I like to use callbacks, but other times a promise is |