sprinkle

0.0.0 • Public • Published

(¯'•.¸(¯º¤ø,¸¸,ø¤º Sprinkles! º¤ø,¸¸,ø¤º¯)¸.•'¯)

Periodically invoke a callback using ticks instead calling setInterval. No memory leaks!

Example

var sprinkle = require("sprinkle"),
fs = require("fs"),
collection = {};
 
//call this function every second or so
var persistData = sprinkle(function() {
    fs.writeFileSync(__dirname + "/collection.json", JSON.stringify(collection));
}, 1000);
 
var storage = {
    get: function(key) {
        return collection[key];
    },
    set: function(key, value) {
        collection[key] = value;
 
        //persist data, but every ~1 second, not every time. It helps
        //if the tick callback is shoved somewhere that's called often.
        persistData(); 
    }
};

/sprinkle/

    Package Sidebar

    Install

    npm i sprinkle

    Weekly Downloads

    1

    Version

    0.0.0

    License

    BSD

    Last publish

    Collaborators

    • lukeed