GitXplorerGitXplorer
m

tiny-timer

public
40 stars
10 forks
2 issues

Commits

List of commits on branch master.
Unverified
1be347bd28f0108dc30370313578f003b5f9f1e4

Update badges

mmathiasvr committed 4 years ago
Unverified
417fb31e3256e8dcae4fdf6c61027531f7ea7eb5

1.6.0

mmathiasvr committed 4 years ago
Unverified
36d5330523bf3f2779f8ca879e7986c537fc7754

Update contributors

mmathiasvr committed 4 years ago
Unverified
467cdb2d03bfb0b3e34462646bf1c7e6b3ad5729

Fix types and clean up

mmathiasvr committed 4 years ago
Unverified
a468077df77e82c126e8e1eff612622ce120fdab

Update dependencies

mmathiasvr committed 4 years ago
Unverified
1b8abb8e0b800ffcd7b25fe1253f2d046fee72d4

Update build

mmathiasvr committed 4 years ago

README

The README file for this repository.

tiny-timer

npm Build Status Dependency status downloads license

Small countdown timer and stopwatch module.

Installation

npm:

$ npm install tiny-timer

Yarn:

$ yarn add tiny-timer

Example

const Timer = require('tiny-timer')

const timer = new Timer()

timer.on('tick', (ms) => console.log('tick', ms))
timer.on('done', () => console.log('done!'))
timer.on('statusChanged', (status) => console.log('status:', status))

timer.start(5000) // run for 5 seconds

Usage

timer = new Timer({ interval: 1000, stopwatch: false })

Optionally set the refresh interval in ms, or stopwatch mode instead of countdown.

timer.start(duration [, interval]) {

Starts timer running for a duration specified in ms. Optionally override the default refresh interval in ms.

timer.stop()

Stops timer.

timer.pause()

Pauses timer.

timer.resume()

Resumes timer.

Events

timer.on('tick', (ms) => {})

Event emitted every interval with the current time in ms.

timer.on('done', () => {})

Event emitted when the timer reaches the duration set by calling timer.start().

timer.on('statusChanged', (status) => {})

Event emitted when the timer status changes.

Properties

timer.time

Gets the current time in ms.

timer.duration

Gets the total duration the timer is running for in ms.

timer.status

Gets the current status of the timer as a string: running, paused or stopped.