0.0.4 • Published 10 years ago

janitorjs v0.0.4

Weekly downloads
1
License
BSD-2-Clause
Repository
github
Last release
10 years ago

Janitor.js is a simple utility that helps cleanup objects. Alt ci

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();