Skip to content

shhhplus/timer.js

Repository files navigation

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

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published