<commit_before>co-gather
=========

Execute thunks, generators, async functions in parallel with concurrency support and gather all the results.

`co-gather` is similar with [co-parallel](https://github.com/visionmedia/co-parallel), but `co-gather` will gather all the result of these thunks, even those thunks throw error.

## Installation

```
$ npm install co-gather
```

## Example

```js
const gather = require('./');
const sleep = require('mz-modules/sleep');

function* gfun(result, error, interval) {
  yield sleep(interval || 100);
  if (error) throw new Error(error);
  return result;
}

async function afun(result, error, interval) {
  await sleep(interval || 100);
  if (error) throw new Error(error);
  return result;
}

console.time('gather');
gather([
  gfun(1),
  gfun(null, 'error'),
  async () => afun(null, 'error'),
  () => afun(4),
], 2).then(res => {
  console.timeEnd('gather');
  console.log(res);
});
```

=>

```
[
  { isError: false, value: 1 },
  { isError: true, error: [Error: error] },
  { isError: true, error: [Error: error] },
  { isError: false, value: 4 }
]
```

## API


## gather(items, [concurrency])

Execute `items` in parallel, with the given concurrency defaulting to 5, and gather the result

## License

MIT<commit_msg>docs: update readme for async function<commit_after>co-gather
=========

Execute thunks, generators, async functions in parallel with concurrency support and gather all the results.

`co-gather` is similar with [co-parallel](https://github.com/visionmedia/co-parallel), but `co-gather` will gather all the result of these thunks, even those thunks throw error.

## Installation

```
$ npm install co-gather
```

## Example

- generator function

```js
const gather = require('./');
const sleep = require('mz-modules/sleep');

function* fun(result, error, interval) {
  yield sleep(interval || 100);
  if (error) throw new Error(error);
  return result;
}

console.time('gather');
gather([
  fun(1),
  fun(null, 'error'),
], 2).then(res => {
  console.timeEnd('gather');
  console.log(res);
});
```

- async function

```js
const gather = require('./');
const sleep = require('mz-modules/sleep');

async function fun(result, error, interval) {
  await sleep(interval || 100);
  if (error) throw new Error(error);
  return result;
}

console.time('gather');
gather([
  () => fun(1),
  async () => fun(null, 'error'),
], 2).then(res => {
  console.timeEnd('gather');
  console.log(res);
});
```
=>

```
[
  { isError: false, value: 1 },
  { isError: true, error: [Error: error] }
]
```

## API


## gather(items, [concurrency])

Execute `items` in parallel, with the given concurrency defaulting to 5, and gather the result

## License

MIT
{'fraction_non_alphanumeric': 0.173639392817475, 'fraction_numerical': 0.008885597926693817, 'mean_word_length': 4.393213572854291, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 12, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '435023', 'n_tokens_mistral': 912, 'n_tokens_neox': 882, 'n_words': 265}