Skip to content
Adds inactivity events to node.js stream objects.
Failed to load latest commit information.
LICENSE new license Jan 21, 2016 Update Nov 16, 2012
index.js first commit Oct 9, 2012
package.json new license Jan 21, 2016
test.js adding verbosity option Nov 8, 2012
tweek.js adding verbosity option Nov 8, 2012


Adds inactivity events to node.js stream objects. alt text


  npm install tweek


  var Tweek = require('tweek');

  var myStream = createMyAmazingStream();

  var options = { patience: 5000, checkInterval: 2000 };

  new Tweek(myStream, options);

  myStream.on('tweek', function (tweek) {
    console.log('tweeked this many times: ', tweek.n);

This will check every 2 seconds to see that the stream has not been inactive for more than 5 seconds.

supertweek, supertweek

You can also set up a second tweek on your stream (if you want to say, send an email on your first tweek, and try reconnecting after a longer period). Adding to the above:

  var options2 = { patience: 25000, checkInterval: 10000, emitEvent: 'supertweek' }
  new Tweek(myStream, options2);

  myStream.on('supertweek', function (tweek) {

optional parameters

You can use the following in your options object:

patience (ms)

How much inactivity can this tweek handle? (default: 3000)

checkInterval (ms)

How often does this tweek check for new activity? (default: 1000)

maxTweeks (int)

How many tweeks should we send you? (default: 5)


What event should I fire? (default: 'tweek')


What event should I listen for? Allows for non-stream event emitters. (default: 'data')


Should I log a bunch of stuff about what I'm doing? (default: 0, ie. No. Please no logs.)

Something went wrong with that request. Please try again.