# mtimer-js

> Managed Timers (interval & timemout) for Javascript

Latest version **1.0.2** (published 2022-08-25) · MIT license · 0 weekly downloads

## Install

```sh
npm install mtimer-js
pnpm add mtimer-js
yarn add mtimer-js
bun add mtimer-js
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.2 |
| Published | 2022-08-25 |
| First published | 2022-08-25 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 11.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Damien Cuvillier |
| Maintainers | damien.cuvillier |
| Keywords | timeout, javascript, interval |

## Links

- npm: https://www.npmjs.com/package/mtimer-js
- Repository: https://github.com/GotanDev/mtimer-js
- Homepage: https://github.com/GotanDev/mtimer-js#readme
- Issues: https://github.com/GotanDev/mtimer-js/issues
- npm.io page: https://npm.io/package/mtimer-js

## Recent versions

- 1.0.2 (latest) — 2022-08-25
- 1.0.1 — 2022-08-25
- 1.0.0 — 2022-08-25

## README

# 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  
```bash
npm i mtimer-js
```
* Bower  
```bash
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:  
```js
{
    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](https://codepen.io/damiencuvillier/pen/RwMmGPW)

## Licence 

[MIT](https://opensource.org/licenses/MIT)

---
_Source: https://npm.io/package/mtimer-js · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
