0.0.5 • Published 12 years ago

tweek v0.0.5

Weekly downloads
23
License
-
Repository
github
Last release
12 years ago

tweek

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

install

  npm install tweek

use

  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) {
    console.log('superTweeeeeeeek!');
  });

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)

emitEvent

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

listenForEvent

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

verbosity

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

0.0.5

12 years ago

0.0.4

12 years ago

0.0.3

12 years ago

0.0.1

12 years ago

0.0.0

12 years ago