Acme.BookStore.HttpApi.Host/node_modules/async-done/README.md
(开头部分) 5KB这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。
<p align="center">
<a href="http://gulpjs.com">
<img height="257" width="114" src="https://raw.githubusercontent.com/gulpjs/artwork/master/gulp-2x.png">
</a>
</p>
# async-done
[![NPM version][npm-image]][npm-url] [![Downloads][downloads-image]][npm-url] [![Azure Pipelines Build Status][azure-pipelines-image]][azure-pipelines-url] [![Travis Build Status][travis-image]][travis-url] [![AppVeyor Build Status][appveyor-image]][appveyor-url] [![Coveralls Status][coveralls-image]][coveralls-url] [![Gitter chat][gitter-image]][gitter-url]
Allows libraries to handle various caller provided asynchronous functions uniformly. Maps promises, observables, child processes and streams, and callbacks to callback style.
As async conventions evolve, it is useful to be able to deal with several different *styles* of async completion uniformly. With this module you can handle completion using a node-style callback, regardless of a return value that's a promise, observable, child process or stream.
## Usage
### Successful completion
```js
var asyncDone = require('async-done');
asyncDone(function(done){
// do async things
done(null, 2);
}, function(error, result){
// `error` will be null on successful execution of the first function.
// `result` will be the result from the first function.
});
```
### Failed completion
```js
var asyncDone = require('async-done');
asyncDone(function(done){
// do async things
done(new Error('Some Error Occurred'));
}, function(error, result){
// `error` will be an error from the first function.
// `result` will be undefined on failed execution of the first function.
});
```
## API
### `asyncDone(fn, callback)`
Takes a function to execute (`fn`) and a function to call on completion (`callback`).
#### `fn([done])`
Optionally takes a callback to call when async tasks are complete.
#### Completion and Error Resolution
* `Callback` (`done`) called
- Completion: called with null error
- Error: called with non-null error
* `Stream` or `EventEmitter` returned
后面还有 61 行代码,解锁后查看完整代码
24 小时内免费解锁 3 个项目,之后 1 积分/个。 规则说明
AI 解读
登录后可用,每次 10 积分,解读结果公开显示在下面。
还没有人解读过这个文件。
