items
Advanced tools
Comparing version 1.1.0 to 1.1.1
@@ -13,5 +13,5 @@ # How to contribute | ||
* Fork the repository on GitHub. | ||
* Fix the issue ensuring that your code follows the [style guide](https://github.com/hapijs/hapi/blob/master/docs/Style.md). | ||
* Fix the issue ensuring that your code follows the [style guide](https://github.com/hapijs/contrib/blob/master/Style.md). | ||
* Add tests for your new code ensuring that you have 100% code coverage (we can help you reach 100% but will not merge without it). | ||
* Run `npm test` to generate a report of test coverage | ||
* [Pull requests](http://help.github.com/send-pull-requests/) should be made to the [master branch](https://github.com/hapijs/items/tree/master). |
{ | ||
"name": "items", | ||
"description": "Bare minimum async methods", | ||
"version": "1.1.0", | ||
"version": "1.1.1", | ||
"repository": "git://github.com/hapijs/items", | ||
"main": "index", | ||
"main": "lib/index.js", | ||
"keywords": [ | ||
@@ -13,3 +13,3 @@ "async", | ||
"engines": { | ||
"node": ">=0.10.30" | ||
"node": ">=0.10.40" | ||
}, | ||
@@ -19,13 +19,10 @@ "dependencies": { | ||
"devDependencies": { | ||
"lab": "4.x.x" | ||
"lab": "5.x.x", | ||
"code": "1.x.x" | ||
}, | ||
"scripts": { | ||
"test": "make test-cov" | ||
"test": "lab -a code -t 100 -L", | ||
"test-cov-html": "lab -a code -r html -o coverage.html" | ||
}, | ||
"licenses": [ | ||
{ | ||
"type": "BSD", | ||
"url": "http://github.com/hapijs/items/raw/master/LICENSE" | ||
} | ||
] | ||
"license": "BSD-3-Clause" | ||
} |
@@ -9,1 +9,35 @@ #items | ||
Lead Maintainer - [Raquel Vélez](https://github.com/rockbot) | ||
## `Items.serial(items, method, callback)` | ||
Runs `method` against each value in the `items` array *in series*. `callback` is executed when all of the tasks are complete. Calling back with an error will short-circuit the remaining tasks. | ||
- `items` an array of items to pass to `method`. | ||
- `method` a function with the signature `function (item, next)`. | ||
- `item` - is the currently processing item in the `items` array. | ||
- `next` - callback function to indicate the end of processing for `item`. Calling `next` with a truthy parameter indicates an error and ends `Items.serial`. | ||
- `callback` - a function with the signature `function (err)`. | ||
- `err` - indicates any errors during processing. | ||
## `Items.parallel(items, method, callback)` | ||
Runs `method` against each value in the `items` array *in parallel*. `callback` is executed when all of the tasks are complete. Calling back with an error will short-circuit the remaining tasks. | ||
- `items` an array of items to pass to `method`. | ||
- `method` a function with the signature `function (item, next)`. | ||
- `item` - is the currently processing item in the `items` array. | ||
- `next` - callback function to indicate the end of processing for `item`. Calling `next` with a truthy parameter indicates an error and ends `Items.serial`. | ||
- `callback` - a function with the signature `function (err)`. | ||
- `err` - indicates any errors during processing. | ||
## `Items.parallel.execute(tasks, callback)` | ||
Runs all of the functions in `tasks` *in parallel* and stores the results in a collector object passed into `callback`. If any of the tasks callback with an error, the collector object is `null`. | ||
- `tasks` - on object containing functions to execute in parallel. The `key` of the function is the `key` in the result of collector object. The task should have the signature `function (next)` | ||
- `next(err, result)` - callback function to indicate the end of processing for the current task. | ||
- `err` - indicates any errors during processing. | ||
- `result` - result of this function. This value will be set on the collector object in the final callback. | ||
- `callback(err, result)` | ||
- `err` - any errors reported by *any* of the `tasks`. | ||
- `result` - an object containing the result of running all of the `tasks`. `result` will be `null` if any of the tasks callback with an error. The `result.key` will be the corresponding `key` of the `tasks` object. |
// Load modules | ||
var Code = require('code'); | ||
var Lab = require('lab'); | ||
@@ -16,4 +17,4 @@ var Items = require('../'); | ||
var describe = lab.experiment; | ||
var it = lab.test; | ||
var expect = Lab.expect; | ||
var it = lab.it; | ||
var expect = Code.expect; | ||
@@ -37,3 +38,3 @@ | ||
expect(err).to.not.exist; | ||
expect(err).to.not.exist(); | ||
expect(called).to.deep.equal(array); | ||
@@ -56,3 +57,3 @@ done(); | ||
expect(err).to.not.exist; | ||
expect(err).to.not.exist(); | ||
expect(called).to.deep.equal(array); | ||
@@ -71,3 +72,3 @@ done(); | ||
if (item === 3) { | ||
return next('error') | ||
return next('error'); | ||
} | ||
@@ -104,3 +105,3 @@ | ||
expect(err).to.not.exist; | ||
expect(err).to.not.exist(); | ||
expect(called).to.deep.equal([1, 3, 4, 2, 5]); | ||
@@ -126,3 +127,3 @@ done(); | ||
expect(err).to.not.exist; | ||
expect(err).to.not.exist(); | ||
expect(called).to.deep.equal([]); | ||
@@ -142,3 +143,3 @@ done(); | ||
if (item[0] === 3) { | ||
return next('error') | ||
return next('error'); | ||
} | ||
@@ -182,3 +183,3 @@ | ||
expect(err).to.not.exist; | ||
expect(err).to.not.exist(); | ||
expect(result.fn1).to.equal('bye'); | ||
@@ -196,3 +197,3 @@ expect(result.fn2).to.equal('hi'); | ||
expect(err).to.not.exist; | ||
expect(err).to.not.exist(); | ||
expect(Object.keys(result).length).to.equal(0); | ||
@@ -207,3 +208,3 @@ done(); | ||
expect(err).to.not.exist; | ||
expect(err).to.not.exist(); | ||
expect(Object.keys(result).length).to.equal(0); | ||
@@ -243,4 +244,4 @@ done(); | ||
expect(err).to.exist; | ||
expect(result).to.not.exist; | ||
expect(err).to.exist(); | ||
expect(result).to.not.exist(); | ||
done(); | ||
@@ -270,4 +271,4 @@ }); | ||
expect(err).to.exist; | ||
expect(result).to.not.exist; | ||
expect(err).to.exist(); | ||
expect(result).to.not.exist(); | ||
expect(fn2Executed).to.equal(false); | ||
@@ -298,4 +299,4 @@ done(); | ||
expect(err).to.exist; | ||
expect(result).to.not.exist; | ||
expect(err).to.exist(); | ||
expect(result).to.not.exist(); | ||
expect(err.message).to.equal('fn1'); | ||
@@ -306,2 +307,2 @@ done(); | ||
}); | ||
}); | ||
}); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
16209
298
42
0
2
8