0.1.2 • Published 6 years ago

@trevorhanus/timer v0.1.2

Weekly downloads
81
License
MIT
Repository
-
Last release
6 years ago

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