Created
February 22, 2019 03:16
-
-
Save nidate/2afbd6c6730283c332c5dad742e76a60 to your computer and use it in GitHub Desktop.
Promisifyの戻り値
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
const promisify = require('util.promisify'); | |
/** | |
* Promisifyはコールバックのパラメータの最初の一つしか返さない。 | |
* | |
* $ node promisify_test.js | |
* [ 'a', undefined, undefined ] | |
* { '0': 'a' } | |
*/ | |
promisify(function(params, callback) { | |
return callback(null, 'a', 'b', 'c'); | |
})({}).then(function(result, a, b) { | |
console.log([result, a, b]); | |
console.log(arguments); | |
}).catch((err) => { | |
console.error(err); | |
}); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment