# respool

> respool

Latest version **0.0.3** (published 2016-01-26) · 0 weekly downloads

## Install

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

## 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.3 |
| Published | 2016-01-26 |
| First published | 2015-08-15 |
| Weekly downloads | 0 |
| TypeScript types | none |
| Module format | CommonJS |
| Node | * |
| Dependencies | 2 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Julien Loutre |
| Maintainers | 26medias |

## Links

- npm: https://www.npmjs.com/package/respool
- Repository: https://github.com/26medias/respool
- Issues: https://github.com/26medias/respool/issues
- npm.io page: https://npm.io/package/respool

## Dependencies (2)

- [progress](https://npm.io/package/progress.md) latest
- [underscore](https://npm.io/package/underscore.md) latest

## Recent versions

- 0.0.3 (latest) — 2016-01-26
- 0.0.2 — 2015-08-28
- 0.0.1 — 2015-08-15

## README

# ResPool #

Instance pooling and load-balancing.

	
	var _ 			= require('underscore');
	var respool 	= require('./respool');
	
	var childClass	= function(callback) {
		this.count	= 0;
		setTimeout(function() {
			callback();
		}, _.random(200,3000));
	};
	childClass.prototype.hit = function () {
		this.count++;
		return this.count;
	};
	
	
	
	var demo	= function(n) {
		var scope	= this;
		this.n		= n;
		this.spool	= new respool({
			async:		false,
			progress:	'Creating...',
			count:		10,
			min:		2,
			create:		function(done) {
				var instance;
				instance = new childClass(function() {
					console.log("> created");
					done(instance);
				});
			}
		});
		this.spool.init(function() {
			console.log("Spool.init()");
			scope.start();
			scope.output();
		});
		
	}
	demo.prototype.start = function() {
		var i;
		console.log("Start", this.n);
		for (i=0;i<this.n;i++) {
			this.spool.instance().hit();
		}
	}
	demo.prototype.output = function() {
		_.each(this.spool.counts, function(count, n) {
			console.log("Instance #"+n, count);
		});
	}
	
	
	var test	= new demo(100);

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