提交 e1580370 编写于 作者: S shikai-123
上级 bcd00305
...@@ -105,7 +105,7 @@ Calls back an asynchronous function. In the callback, the first parameter indica ...@@ -105,7 +105,7 @@ Calls back an asynchronous function. In the callback, the first parameter indica
promiseWrapper(original: (err: Object, value: Object) => void): Object promiseWrapper(original: (err: Object, value: Object) => void): Object
> **Introduce**<br/> > **Introduce**<br/>
> Starting from API version 9, it is recommended to use [util.promisewrapper9 +] (\utilpromisewrapper9) instead. > Deprecated starting from API version 9, it is recommended to use [util.promisify9 +] (\utilpromisify9) instead.
Processes an asynchronous function and returns a promise version. Processes an asynchronous function and returns a promise version.
...@@ -132,9 +132,9 @@ Processes an asynchronous function and returns a promise version. ...@@ -132,9 +132,9 @@ Processes an asynchronous function and returns a promise version.
}) })
``` ```
## util.promiseWrapper<sup>9+</sup> ## util.promisify<sup>9+</sup>
promiseWrapper(original: (err: Object, value: Object) =&gt; void): Function promisify(original: (err: Object, value: Object) =&gt; void): Function
Processes an asynchronous function and returns a promise function. Processes an asynchronous function and returns a promise function.
...@@ -159,7 +159,7 @@ Processes an asynchronous function and returns a promise function. ...@@ -159,7 +159,7 @@ Processes an asynchronous function and returns a promise function.
return str1 return str1
} }
} }
let newPromiseObj = util.promiseWrapper(aysnFun); let newPromiseObj = util.promisify(aysnFun);
newPromiseObj({ err: "type error" }, {value:'HelloWorld'}).then(res => { newPromiseObj({ err: "type error" }, {value:'HelloWorld'}).then(res => {
console.log(res); console.log(res);
}) })
......
...@@ -104,7 +104,7 @@ callbackWrapper(original: Function): (err: Object, value: Object )=&gt;void ...@@ -104,7 +104,7 @@ callbackWrapper(original: Function): (err: Object, value: Object )=&gt;void
promiseWrapper(original: (err: Object, value: Object) =&gt; void): Object promiseWrapper(original: (err: Object, value: Object) =&gt; void): Object
> **说明:**<br/> > **说明:**<br/>
> 从API Version 9开始废弃,建议使用[util.promiseWrapper9+](#utilpromisewrapper9)替代。 > 从API Version 9开始废弃,建议使用[util.promisify9+](#utilpromisify9)替代。
对异步函数处理并返回一个promise的版本。 对异步函数处理并返回一个promise的版本。
...@@ -131,9 +131,9 @@ promiseWrapper(original: (err: Object, value: Object) =&gt; void): Object ...@@ -131,9 +131,9 @@ promiseWrapper(original: (err: Object, value: Object) =&gt; void): Object
}) })
``` ```
## util.promiseWrapper<sup>9+</sup> ## util.promisify<sup>9+</sup>
promiseWrapper(original: (err: Object, value: Object) =&gt; void): Function promisify(original: (err: Object, value: Object) =&gt; void): Function
对异步函数处理并返回一个promise的函数。 对异步函数处理并返回一个promise的函数。
...@@ -158,7 +158,7 @@ promiseWrapper(original: (err: Object, value: Object) =&gt; void): Function ...@@ -158,7 +158,7 @@ promiseWrapper(original: (err: Object, value: Object) =&gt; void): Function
return str1 return str1
} }
} }
let newPromiseObj = util.promiseWrapper(aysnFun); let newPromiseObj = util.promisify(aysnFun);
newPromiseObj({ err: "type error" }, {value:'HelloWorld'}).then(res => { newPromiseObj({ err: "type error" }, {value:'HelloWorld'}).then(res => {
console.log(res); console.log(res);
}) })
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册