You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+26
Original file line number
Diff line number
Diff line change
@@ -1783,6 +1783,32 @@ async.waterfall([
1783
1783
], callback)
1784
1784
```
1785
1785
1786
+
If the function passed to `asyncify` returns a Promise, that promises's resolved/rejected state will be used to call the callback, rather than simply the synchronous return value. Example:
1787
+
1788
+
```js
1789
+
async.waterfall([
1790
+
async.apply(fs.readFile, filename, "utf8"),
1791
+
async.asyncify(function (contents) {
1792
+
returndb.model.create(contents);
1793
+
}),
1794
+
function (model, next) {
1795
+
// `model` is the instantiated model object.
1796
+
// If there was an error, this function would be skipped.
1797
+
}
1798
+
], callback)
1799
+
```
1800
+
1801
+
This also means you can asyncify ES2016 `async` functions.
1802
+
1803
+
```js
1804
+
var q =async.queue(async.asyncify(asyncfunction (file) {
0 commit comments