snitch

Monitor if a file/directory is growing in size and execute a callback function when its size is stabilized.

#snitch

A node.js module that allows to monitor if a file/directory is growing in size and execute a callback function when its size is stabilized.

##Install Install globally with npm:

    $ npm install snitch -g 

##Usage The snitch module exports the onStopGrowing function. The onStopGrowing function checks in configurable intervals the size of a file/directory. When two consecutive size-checks return the same size, a final pollings mechanism is triggered. If during the final polling the file/directory-size remained the same the callback is invoked.

If you want to use the module with default settings just pass as arguments a file/directory-path and the callback you want to invoke

var snitch = require('snitch');        
 
snitch.onStopGrowing(path, callback);

##Options

If you want to override the default options of the module, the 'onStopGrowing' function accepts as a third argument an object with three configurable properties. You can either override one, or all of them.

 var options = {
        interval: x, // in milliseconds 
        pollingTimes: y, // a number 
        timeout: z // in milliseconds 
    };
    
 snitch.onStopGrowing(path, callback, options);
  • interval : Time interval between size checks. Default is 3000
  • pollingTimes: Number of polling times during final polling. Default is 5
  • timeout: Timeout of function. Default is 30 * 60000 (30 minutes)

##Test Run the tests

    $ npm test 

##License Copyright (c) 2014 Ioannis Tzanellis
Released under the MIT license