2.0.5 • Published 2 years ago

@shhhplus/timer.js v2.0.5

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

timer.js

GitHub license npm version codecov build status

This timer is very simple and framework independent.

Install

npm install @shhhplus/timer.js --save

How to use

sync

import createTimer from '@shhhplus/timer.js';

const timer = createTimer({
  interval: 1000,
  onElapsed: () => {
    console.log('onElapsed ...');
  },
});

timer.start();

timer.stop();

async

import createTimer from '@shhhplus/timer.js';

const timer = createTimer({
  interval: 5000,
  onElapsed: () => {
    console.log('onElapsed ...');
    return new Promise((resolve) => {
      setTimeout(resolve, 500);
    });
  },
});

timer.start();

timer.stop();