# gatherer

> Fire a callback when a whole bunch of other callbacks are complete

Latest version **0.0.1** (published 2012-05-05) · 0 weekly downloads

## Install

```sh
npm install gatherer
pnpm add gatherer
yarn add gatherer
bun add gatherer
```

## Health

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

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; low quality score; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.1 |
| Published | 2012-05-05 |
| First published | 2012-05-05 |
| Weekly downloads | 0 |
| TypeScript types | none |
| Module format | CommonJS |
| Node | * |
| Dependencies | 2 |
| Known vulnerabilities | 0 (+2 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 2 |
| Author | Charlotte Gore |
| Maintainers | CharlotteGore |
| Keywords | async, callbacks |

## Links

- npm: https://www.npmjs.com/package/gatherer
- Repository: https://github.com/CharlotteGore/Gatherer
- Homepage: https://CharlotteGore@github.com/CharlotteGore/Gatherer.git
- npm.io page: https://npm.io/package/gatherer

## Dependencies (2)

- [underscore](https://npm.io/package/underscore.md) 1.3.x
- [base-framework](https://npm.io/package/base-framework.md) 1.0.x

## Alternatives

- [@commercetools/sync-actions](https://npm.io/package/@commercetools/sync-actions.md) — 25.1K weekly downloads
- [cwait](https://npm.io/package/cwait.md) — 21.4K weekly downloads
- [@ledgerhq/hw-app-cosmos](https://npm.io/package/@ledgerhq/hw-app-cosmos.md) — 4.2K weekly downloads
- [@financial-times/o-loading](https://npm.io/package/@financial-times/o-loading.md) — 2.8K weekly downloads
- [fa](https://npm.io/package/fa.md) — 185 weekly downloads

## Recent versions

- 0.0.1 (latest) — 2012-05-05

## README

#Gatherer

## Intro

When developing Node.js applications sometimes you need to know when a whole bunch of callbacks have finished. You *could* just use synchronous methods, but that defeats the point of using Node, doesn't it? 

Gatherer lets you set a callback to be run after a whole bunch of other callbacks have returned, but because that sounds incredibly boring it uses a metaphor of parties:

Invite your guests to your gathering.
Once all your guests have accepted their invites, start the party!

### The Code

To install

	npm install gatherer
	cd node_modules/gatherer
	npm install

In your javascript file.

	var gathering = require('gatherer');

## Creating a party

Create a new gathering..

	var gathering = gatherer(); 

Create your invitations...

	_.each(files, function( file ){
		gathering.createInvitation( function( accept, decline ){
			fs.readFile( file, 'utf8', function( err, data ){
				if( !err ){
					// do something with your file data..
					accept();
				} else {
					decline();
				}
			});
		});
		
	});

Send the invitations, executing a callback when they're done. Returns 'err' if there's an err, otherwise nothing.

	gathering.sendInvitations(function(err){
		if(!err){
			// all invites were accepted
		} else {
			// some invites were declined... err === number of declines
		}
	});

You can also set a limit on how long you want to wait for the invites:

	gathering.sendInvitations(function(){
		if(err==='Error: Timed out'){
			// it waited 2000 miliseconds then gave up			
		}
	}, { timeout : 2000 }) // will give up after 2000 ms. Warning: This doesn't cancel the execution of callbacks that are still running.


### Run the tests

You need mocha and should.js.

	make test

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