@nanomatic/timer
v1.1.4
Published
Implementation of the reuseable timer
Downloads
2
Readme
📝 Table of Contents
🏁 Getting Started
Installing
npm i @nanomatic/timer
Using
Example code below:
import { Timer } from '@nanomatic/timer';
const timer = new Timer;
// Time to countdown in s
timer.time = 5;
// tslint:disable-next-line: no-console
timer.start();
// tslint:disable-next-line: no-console
setInterval(() => console.log(`Elapsed time: ${timer.elapsedTime.toFixed(3)}s / ${timer.time.toFixed(3)}s Reamining time: ${timer.remainingTime.toFixed(3)}s / 0s ${timer.done ? 'Done' : ''}`), 100);
// Simulation
setTimeout(() => timer.pause(), 2000);
setTimeout(() => timer.resume(), 5000);
setTimeout(() => timer.reset(false), 10000);
setTimeout(() => {
timer.time = 0;
timer.start();
}, 13000);
⛏️ Built With
- ts-node-dev - TypeScript Node Dev
- tsc-watch - The nodemon for TypeScript
- TSLint - TypeScript linter
- NodeJs - Test Environment
✍️ Authors
- @NANOmatic - Idea & Initial work
🎉 Acknowledgments
- Special thanks for Sebastian for working together and giving ideas 😉