Skip to content
cleanup utility for JavaScript
JavaScript
Find file
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.
lib
test
.gitignore
.travis.yml
README.md
bower.json
package.json

README.md

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();
Something went wrong with that request. Please try again.