1#items
2
3Bare minimum async methods adapted specifically for the very limited **hapi** core use cases. Use
4[async](https://github.com/caolan/async) for all your application needs.
5
6[![Build Status](https://secure.travis-ci.org/hapijs/items.png)](http://travis-ci.org/hapijs/items)
7
8Lead Maintainer - [Raquel Vélez](https://github.com/rockbot)
9
10## `Items.serial(items, method, callback)`
11
12Runs `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.
13
14- `items` an array of items to pass to `method`.
15- `method` a function with the signature `function (item, next, i)`.
16    - `item` - is the currently processing item in the `items` array.
17    - `next` - callback function to indicate the end of processing for `item`. Calling `next` with a truthy parameter indicates an error and ends `Items.serial`.
18    - `i` - The current item's index in the `items` array.
19- `callback` - a function with the signature `function (err)`.
20    - `err` - indicates any errors during processing.
21
22## `Items.parallel(items, method, callback)`
23
24Runs `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.
25
26- `items` an array of items to pass to `method`.
27- `method` a function with the signature `function (item, next, i)`.
28    - `item` - is the currently processing item in the `items` array.
29    - `next` - callback function to indicate the end of processing for `item`. Calling `next` with a truthy parameter indicates an error and ends `Items.parallel`.
30    - `i` - The current item's index in the `items` array.
31- `callback` - a function with the signature `function (err)`.
32    - `err` - indicates any errors during processing.
33
34## `Items.parallel.execute(tasks, callback)`
35
36Runs 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`.
37
38- `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)`
39    - `next(err, result)` - callback function to indicate the end of processing for the current task.
40        - `err` - indicates any errors during processing.
41        - `result` - result of this function. This value will be set on the collector object in the final callback.
42- `callback(err, result)`
43    - `err` - any errors reported by *any* of the `tasks`.
44    - `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.
45