commit
f67d7ad3fe
1 changed files with 2 additions and 2 deletions
|
@ -30,7 +30,7 @@ let loadScriptPromise = function(src) {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
loadScript(src, (err, script) => {
|
loadScript(src, (err, script) => {
|
||||||
if (err) reject(err)
|
if (err) reject(err)
|
||||||
elsee resolve(script);
|
else resolve(script);
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -75,7 +75,7 @@ loadScriptPromise(...).then(...);
|
||||||
|
|
||||||
Here we assume that the original function expects a callback with two arguments `(err, result)`. That's what we meet most often. Then our custom callbacks is exactly in the right format, and `promisify` works great for such case.
|
Here we assume that the original function expects a callback with two arguments `(err, result)`. That's what we meet most often. Then our custom callbacks is exactly in the right format, and `promisify` works great for such case.
|
||||||
|
|
||||||
But what is the original `f` expects a callback with more arguments `callback(err, res1, res2)`?
|
But what if the original `f` expects a callback with more arguments `callback(err, res1, res2)`?
|
||||||
|
|
||||||
Here's a modification of `promisify` that returns an array of multiple callback results:
|
Here's a modification of `promisify` that returns an array of multiple callback results:
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue