async-settle
Advanced tools
Comparing version 0.2.1 to 1.0.0
@@ -5,7 +5,7 @@ 'use strict'; | ||
function settle(fn, done){ | ||
asyncDone(fn, function(error, result){ | ||
function settle(fn, done) { | ||
asyncDone(fn, function(error, result) { | ||
var settled = {}; | ||
if(error != null){ | ||
if (error != null) { | ||
settled.state = 'error'; | ||
@@ -12,0 +12,0 @@ settled.value = error; |
{ | ||
"name": "async-settle", | ||
"version": "0.2.1", | ||
"description": "Settle your async functions - when you need to know all your parallel functions are complete (success or failure)", | ||
"version": "1.0.0", | ||
"description": "Settle an async function.", | ||
"author": "Gulp Team <team@gulpjs.com> (http://gulpjs.com/)", | ||
"contributors": [ | ||
"Blaine Bublitz <blaine.bublitz@gmail.com>" | ||
], | ||
"repository": "gulpjs/async-settle", | ||
"license": "MIT", | ||
"engines": { | ||
"node": ">= 0.10" | ||
}, | ||
"main": "index.js", | ||
"directories": { | ||
"test": "test" | ||
}, | ||
"files": [ | ||
"index.js", | ||
"LICENSE" | ||
], | ||
"scripts": { | ||
"test": "tap ./test" | ||
"lint": "eslint . && jscs index.js test/", | ||
"pretest": "npm run lint", | ||
"test": "mocha --async-only", | ||
"cover": "istanbul cover _mocha --report lcovonly", | ||
"coveralls": "npm run cover && istanbul-coveralls" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "git://github.com/phated/async-settle" | ||
"dependencies": { | ||
"async-done": "^1.2.2" | ||
}, | ||
"devDependencies": { | ||
"eslint": "^1.7.3", | ||
"eslint-config-gulp": "^2.0.0", | ||
"expect": "^1.19.0", | ||
"istanbul": "^0.4.3", | ||
"istanbul-coveralls": "^1.0.3", | ||
"jscs": "^2.3.5", | ||
"jscs-preset-gulp": "^1.0.0", | ||
"mocha": "^2.4.5" | ||
}, | ||
"keywords": [ | ||
@@ -23,15 +46,3 @@ "settle", | ||
"parallel" | ||
], | ||
"author": "Blaine Bublitz <blaine@iceddev.com> (http://iceddev.com/)", | ||
"license": "MIT", | ||
"bugs": { | ||
"url": "https://github.com/phated/async-settle/issues" | ||
}, | ||
"homepage": "https://github.com/phated/async-settle", | ||
"devDependencies": { | ||
"tap": "^0.4.8" | ||
}, | ||
"dependencies": { | ||
"async-done": "^0.4.0" | ||
} | ||
] | ||
} |
@@ -1,20 +0,69 @@ | ||
async-settle | ||
============ | ||
<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> | ||
[![build status](https://secure.travis-ci.org/phated/async-settle.png)](http://travis-ci.org/phated/async-settle) | ||
# async-settle | ||
Settle your async functions - when you need to know all your parallel functions are complete (success or failure) | ||
[![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 | ||
### `settle(executor, onComplete)` : Function | ||
### `asyncSettle(fn, callback)` | ||
Takes a function to execute (`executor`) and a function to call on completion (`onComplete`). | ||
Takes a function to execute (`fn`) and a function to call on completion (`callback`). | ||
`executer` is executed in the context of [`async-done`](https://github.com/phated/async-done), with all errors and results being settled. | ||
#### `fn([done])` | ||
`onComplete` will be called with a settled value. | ||
Optionally takes a callback (`done`) to call when async tasks are complete. | ||
#### Settled Values | ||
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]. | ||
#### `callback(error, result)` | ||
Called on completion of `fn` and recieves a settled object as the `result` argument. | ||
The `error` argument will always be `null`. | ||
#### Settled Object | ||
Settled values have two properties, `state` and `value`. | ||
@@ -29,1 +78,20 @@ | ||
MIT | ||
[async-done]: https://github.com/gulpjs/async-done | ||
[completions]: https://github.com/gulpjs/async-done#completion-and-error-resolution | ||
[downloads-image]: http://img.shields.io/npm/dm/async-settle.svg | ||
[npm-url]: https://www.npmjs.com/package/async-settle | ||
[npm-image]: http://img.shields.io/npm/v/async-settle.svg | ||
[travis-url]: https://travis-ci.org/gulpjs/async-settle | ||
[travis-image]: http://img.shields.io/travis/gulpjs/async-settle.svg?label=travis-ci | ||
[appveyor-url]: https://ci.appveyor.com/project/gulpjs/async-settle | ||
[appveyor-image]: https://img.shields.io/appveyor/ci/gulpjs/async-settle.svg?label=appveyor | ||
[coveralls-url]: https://coveralls.io/r/gulpjs/async-settle | ||
[coveralls-image]: http://img.shields.io/coveralls/gulpjs/async-settle/master.svg | ||
[gitter-url]: https://gitter.im/gulpjs/gulp | ||
[gitter-image]: https://badges.gitter.im/gulpjs/gulp.svg |
Sorry, the diff of this file is not supported yet
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
5659
0
97
8
4
16
+ Addedasync-done@1.3.2(transitive)
+ Addedend-of-stream@1.4.4(transitive)
+ Addedprocess-nextick-args@2.0.1(transitive)
- Removedasync-done@0.4.0(transitive)
- Removedend-of-stream@0.1.5(transitive)
- Removednext-tick@0.2.2(transitive)
- Removedonce@1.3.3(transitive)
Updatedasync-done@^1.2.2