1.0.2 • Published 2 years ago

mtimer-js v1.0.2

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

MTimer JS

Managed Timers (interval & timemout) for Javascript

Override default setInterval and setTimeout functions to allow better management.

Allows to list, stop, clear any launched timer.

Setup

  • NPM
npm i mtimer-js
  • Bower
bower install --save git@github.com:GotanDev/mtimer-js.git

Documentation

  • Just use setTimeout & setInterval, clearInterval, clearTimeout functions as usual
  • window.timers global variable includes now all active timers details.
    Each items has the following structure:
{
    id: Number,
    type: 'interval'|'timeout',
    functionName: String,
    delay: Number,
    startTime: Date
}
  • Additionally on overrided basic functions , you can also get 2 additionnal functions:
    • clearTimer(timerId:number):
      Clear a timer from its id
      (either created by setInterval ou setTimeout functions)
    • clearTimers(typeFilter: 'interval'|'timeout'):
      Reset all known active timers (timeouts and intervals) You can specify either timeout or interval
      Default value: both

Sample

CodePen

Licence

MIT