# child-queue

> Creates child processes to handle a queue of inputs

Latest version **0.0.1** (published 2015-01-05) · MIT license · 0 weekly downloads

## Install

```sh
npm install child-queue
pnpm add child-queue
yarn add child-queue
bun add child-queue
```

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.1 |
| Published | 2015-01-05 |
| First published | 2015-01-05 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Paul Sauve |
| Maintainers | paulbgd |
| Keywords | node-child-queue, process, input, thread |

## Links

- npm: https://www.npmjs.com/package/child-queue
- Repository: https://github.com/PaulBGD/node-child-queue
- Issues: https://github.com/PaulBGD/node-child-queue/issues
- npm.io page: https://npm.io/package/child-queue

## Alternatives

- [cron](https://npm.io/package/cron.md) — 4.9M weekly downloads
- [@vercel/queue](https://npm.io/package/@vercel/queue.md) — 731.6K weekly downloads
- [create-sonicjs](https://npm.io/package/create-sonicjs.md) — 1.6K weekly downloads
- [@exellix/jobs-api](https://npm.io/package/@exellix/jobs-api.md) — 941 weekly downloads
- [@forwardimpact/libskill](https://npm.io/package/@forwardimpact/libskill.md) — 575 weekly downloads

## Recent versions

- 0.0.1 (latest) — 2015-01-05

## README

# Node Child Queue

Allow complex tasks to be queued and processed by child processes to speed up your Node application.

## Examples

*main.js*
```js
var Queue = require("child-queue");
var queue = new Queue(require.resolve("./child"));
queue.request({type: "weather", area: "New York"}, function(err, result) {
    if (err) {
        throw err;
    }
    console.log("The weather in New York is " + result.toLowerCase());
    queue.close(true);
});
```

*child.js*
```js
var http = require("http");
module.exports = function(input, callback) {
    if (input.type == "weather") {
        http.get('http://api.openweathermap.org/data/2.5/weather?q=' + input.area, function(res) {
            var body = '';

            res.on('data', function(chunk) {
                body += chunk;
            });

            res.on('end', function() {
                try {
                    callback(undefined, JSON.parse(body).weather[0].main);
                } catch (err) {
                    callback(err);
                }
            });
        }).on('error', function(e) {
            callback(e);
        });
    }
};
```

## API

The included API is quite simple to understand

### `new Queue([options, ]pathToChild)`

Creates a new queue to handle processes. The pathToChild should be *relative*.

### `options`

If you don't supply an options object, the following will be used

```js
{
    maxProcesses: 5,
    preLoadChildren: false,
    allowOverflow: true
}
```

* `maxProcesses` the most child processes you want running at a single time
* `preLoadChildren` when set, the child processes will be created before giving an input
* `allowOverflow` allows you to give an input even when all processes are busy. It will be inputted whenever a process is ready

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