@shhhplus/timer.js
TypeScript icon, indicating that this package has built-in type declarations

2.0.5 • Public • Published

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

/@shhhplus/timer.js/

    Package Sidebar

    Install

    npm i @shhhplus/timer.js

    Weekly Downloads

    0

    Version

    2.0.5

    License

    MIT

    Unpacked Size

    3.64 kB

    Total Files

    5

    Last publish

    Collaborators

    • shhhplus