# co-gather

> Execute thunks in parallel with concurrency support and gather all the results

Latest version **1.0.1** (published 2020-03-11) · MIT license · 0 weekly downloads

## Install

```sh
npm install co-gather
pnpm add co-gather
yarn add co-gather
bun add co-gather
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.1 |
| Published | 2020-03-11 |
| First published | 2014-03-06 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 5.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 16 |
| Author | dead_horse |
| Maintainers | dead_horse |
| Keywords | co, parallel, gather, koa |

## Links

- npm: https://www.npmjs.com/package/co-gather
- Repository: https://github.com/cojs/gather
- Issues: https://github.com/cojs/gather/issues
- npm.io page: https://npm.io/package/co-gather

## Dependencies (1)

- [co](https://npm.io/package/co.md) ^4.6.0

## Alternatives

- [flatbuffers](https://npm.io/package/flatbuffers.md) — 6.0M weekly downloads
- [jwt-simple](https://npm.io/package/jwt-simple.md) — 259.5K weekly downloads
- [@exodus/patch-broken-hermes-typed-arrays](https://npm.io/package/@exodus/patch-broken-hermes-typed-arrays.md) — 28.5K weekly downloads
- [@native-to-anchor/buffer-layout](https://npm.io/package/@native-to-anchor/buffer-layout.md) — 12.2K weekly downloads
- [binary-parser-encoder](https://npm.io/package/binary-parser-encoder.md) — 5.3K weekly downloads

## Recent versions

- 1.0.1 (latest) — 2020-03-11
- 1.0.0 — 2018-07-25
- 0.0.1 — 2014-03-06

## README

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

---
_Source: https://npm.io/package/co-gather · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
