1.0.1 • Published 5 years ago
@wavevision/timer v1.0.1
Simple utility for creating resumable timeouts written in TypeScript. Works both in Node and browser environments.
Installation
Via Yarn
yarn add @wavevision/timeror npm
npm install --save @wavevision/timerUsage
Create your own timer.
import timer from '@wavevision/timer';
timer(() => alert('Time is up!'), 1000);
// this timer will be auto-started
timer(() => alert('Hello!'), 500, true);The returned object exposes following functions:
clear(): void– clears the timeoutpause(): number– pauses the timeout, returns remaining timeremains(): number– returns remaining timerestart(): void– clears and starts the timeout over againresume(): void– resumes the timeout (or starts if not running)running(): boolean– returns whether the timeout is running at the momentstart(): void– starts the timeout (or resumes if paused)