duck-timer
TypeScript icon, indicating that this package has built-in type declarations

1.0.3 • Public • Published

DuckTimer

Node.js CI npm version Downloads

A helpful timer class for both of browsers and node.js.

Installation

npm install duck-timer

Usage

Stopwatch

import DuckTimer from 'duck-timer';
const timer = new DuckTimer({ interval: 100 }); // interval time: 100ms = 0.1sec.

// start.
timer.onInterval(res => {
  console.log(res.seconds);
}).start();

// stop.
timer.stop();

// reset.
timer.reset();

Countdown

import DuckTimer from 'duck-timer';
const timer = new DuckTimer({ interval: 1000 });

timer.setCountdown(`Dec 25, ${new Date().getFullYear()}`)
  .onInterval(res => console.log(res.remain.seconds))
  .onTimeout(() => console.log('Merry Christmas!!!'))
  .start();

API

Please see DuckTimer API.

License

MIT License

Readme

Keywords

Package Sidebar

Install

npm i duck-timer

Weekly Downloads

23

Version

1.0.3

License

MIT

Unpacked Size

113 kB

Total Files

26

Last publish

Collaborators

  • archco