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

0.1.2 • Public • Published

Timer

A simple timer utility that allows you to register and cancel timeouts easily.

Install

$ yarn install @trevorhanus/timer

Usage

import {Timer} from '@trevorhanus/timer'
  
const timer = new Timer();
  
// register a callback
timer.register('first', () => console.log('The first timer is done.'), 1000);
  
// check to see if the timer is pending
let pending = timer.isPending('first'); // will be true
  
// cancel the timer
timer.cancel('first');
  
// pending will be false
// and the callback will not be invoked
let pending = timer.isPending('first'); // will be false

Readme

Keywords

none

Package Sidebar

Install

npm i @trevorhanus/timer

Weekly Downloads

35

Version

0.1.2

License

MIT

Last publish

Collaborators

  • trevorhanus