Acme.BookStore.HttpApi.Host/node_modules/async-settle/README.md
(开头部分) 3KB这里只显示每个文件的开头 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-settle
[![NPM version][npm-image]][npm-url] [![Downloads][downloads-image]][npm-url] [![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]
Settle an async function. It will always complete successfully with an object of the resulting state.
Handles completion and errors for callbacks, promises, observables and streams.
Will run call the function on `nextTick`. This will cause all functions to be async.
## Usage
### Successful completion
```js
var asyncSettle = require('async-settle');
asyncSettle(function(done){
// do async things
done(null, 2);
}, function(error, result){
// `error` will ALWAYS be null on execution of the first function.
// `result` will ALWAYS be a settled object with the result or error of the first function.
});
```
### Failed completion
```js
var asyncSettle = require('async-settle');
asyncSettle(function(done){
// do async things
done(new Error('Some Error Occurred'));
}, function(error, result){
// `error` will ALWAYS be null on execution of the first function.
// `result` will ALWAYS be a settled object with the result or error of the first function.
});
```
## API
### `asyncSettle(fn, callback)`
Takes a function to execute (`fn`) and a function to call on completion (`callback`).
#### `fn([done])`
Optionally takes a callback (`done`) to call when async tasks are complete.
Executed in the context of [`async-done`][async-done], with all errors and results being settled.
Completion is handled by [`async-done` completion and error resolution][completions].
后面还有 36 行代码,解锁后查看完整代码
24 小时内免费解锁 3 个项目,之后 1 积分/个。 规则说明
AI 解读
登录后可用,每次 10 积分,解读结果公开显示在下面。
还没有人解读过这个文件。
