# limit-spawn

> Kills a child process created with spawn after X bytes are sent

Latest version **0.0.3** (published 2014-05-21) · MIT license · 0 weekly downloads

## Install

```sh
npm install limit-spawn
pnpm add limit-spawn
yarn add limit-spawn
bun add limit-spawn
```

## 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.3 |
| Published | 2014-05-21 |
| First published | 2013-08-02 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >= 0.8.0 |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 2 |
| Author | Alexandru Vladutu |
| Maintainers | alessioalex |
| Keywords | spawn, limit |

## Links

- npm: https://www.npmjs.com/package/limit-spawn
- Repository: https://github.com/alessioalex/limit-spawn
- Issues: https://github.com/alessioalex/limit-spawn/issues
- npm.io page: https://npm.io/package/limit-spawn

## 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.3 (latest) — 2014-05-21
- 0.0.2 — 2013-08-02
- 0.0.1 — 2013-08-02

## README

# limit-spawn

### Description

Kills a child process created with spawn after X bytes are sent and emits an event.

### Installation

```bash
npm install limit-spawn
```
### Note

This is a soft limit, meaning that after more than MAX data is received the process is closed and the 'max-limit-exceeded' is emitted.
So this implies that you can receive more data than the limit (depending on the last chunk).

### Examples

```js
var spawn  = require('child_process').spawn,
    limit  = require('../index'),
    assert = require('assert'),
    child, ps, bytesReceived, MAX_LIMIT;

MAX_LIMIT = 100 * 1024; // 100 Kb

child = spawn('node', ['forever-output.js'], {
  cwd: __dirname
});

limit(child, MAX_LIMIT);

bytesReceived = 0;

child.stdout.on('data', function(data) {
  bytesReceived += data.length;
});

child.stderr.pipe(process.stderr);

child.on('max-limit-exceeded', function(size) {
  console.log('limit exceeded: ' + parseInt(size / 1024, 10) + ' Kb sent');
});

// shortly after the 'max-limit-exceeded' event is emitted the child dies
child.on('close', function(code) {
  console.log('child process exited');
});
```

### Tests

```bash
npm test
```

## License

MIT

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