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

1.1.4 • Public • Published

Timer

@nanomatic/timer

Status License


Implementation of the reuseable timer

📝 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

✍️ Authors

🎉 Acknowledgments

  • Special thanks for Sebastian for working together and giving ideas 😉

Readme

Keywords

Package Sidebar

Install

npm i @nanomatic/timer

Homepage

nanomatic.pl

Weekly Downloads

0

Version

1.1.4

License

MIT

Unpacked Size

6.04 kB

Total Files

4

Last publish

Collaborators

  • nano_matic