janitorjs

0.0.4 • Public • Published

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

Readme

Keywords

none

Package Sidebar

Install

npm i janitorjs

Weekly Downloads

2

Version

0.0.4

License

BSD-2-Clause

Last publish

Collaborators

  • architectd
  • crcn