Kills a child process created with spawn after X bytes are sent
Kills a child process created with spawn after X bytes are sent and emits an event.
npm install limit-spawn
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).
var spawn = require'child_process'spawnlimit = require'../index'assert = require'assert'child ps bytesReceived MAX_LIMIT;MAX_LIMIT = 100 * 1024; // 100 Kbchild = spawn'node' 'forever-output.js'cwd: __dirname;limitchild MAX_LIMIT;bytesReceived = 0;childstdouton'data'bytesReceived += datalength;;childstderrpipeprocessstderr;childon'max-limit-exceeded'console.log'limit exceeded: ' + parseIntsize / 1024 10 + ' Kb sent';;// shortly after the 'max-limit-exceeded' event is emitted the child dieschildon'close'console.log'child process exited';;