janitorjs
v0.0.4
Published
janitor.js ==========
Downloads
20
Readme
Janitor.js is a simple utility that helps cleanup objects.
installation
Via NPM:
npm install janitorjs
Via Bower:
bower install janitor
API
janitor()
Creates a new janitor
janitor.add(fnOrDisposable)
adds a disposable item to be cleaned up later.
// function
janitor.add(function() {
});
// *or* object with .dispose() method
janitor.add({
dispose: function() {
}
});
janitor.addTimeout(timer)
adds a timeout object
janitor.addTimeout(setTimeout(function() {
}, 1000));
janitor.addInterval(timer)
adds an interval object
janitor.addInterval(setInterval(function() {
}, 100));
janitor.dispose()
janitor.add(function() { });
janitor.addInterval(setInterval(functon(){}, 100));
//call the first fn, and dispose the interval
janitor.dispose();