node 提倡异步回调的事件模型
内置异步函数都是回调形式,可以转为 promise, node 提供了内置的工具函数来实现:
util 包的 promisify 函数

下面自己手写一个 promisify 函数:其它的还有类似 bluebird 的第三方库,功能更加强大。常用的有 promisify 和 promisifyAll 方法


node 提倡异步回调的事件模型
内置异步函数都是回调形式,可以转为 promise, node 提供了内置的工具函数来实现:
util 包的 promisify 函数
下面自己手写一个 promisify 函数:其它的还有类似 bluebird 的第三方库,功能更加强大。常用的有 promisify 和 promisifyAll 方法
本文标题:回调函数 promise 化
本文链接:https://www.haomeiwen.com/subject/wzydxctx.html
网友评论