minimal-timer

4.1.0 • Public • Published

minimal-timer

Keeps track of the elapsed time in miliseconds.

Build Status npm version JavaScript Style Guide

Install

$ npm install minimal-timer --save

Usage

const delay = require('delay')
const timer = require('minimal-timer')
 
const time = timer() // instantiates the timer
 
time.start()
 
await delay(500)
 
console.log(time.elapsedTime()) // => 500 +- 
 
time.stop()
 
await delay(500)
 
console.log(time.elapsedTime()) // => 500 +- 
 
time.resume()
 
await delay(500)
 
console.log(time.elapsedTime()) // => 1000 +- 
 

API

timer() object

Creates a new instance

start(customStartDate[optional]) void

Starts/Restart the timer

customStartDate Date [optional]

resume() void

Resumes the timer.

stop() number

Stops the timer

Returns the elapsed time in miliseconds

elapsedTime() number

Returns the elapased between the start time and the current time in miliseconds

isRunning() boolean

Returns true if the timer is running otherwise false

License

MIT © Alvaro Bernal

Package Sidebar

Install

npm i minimal-timer

Weekly Downloads

36

Version

4.1.0

License

M.I.T

Last publish

Collaborators

  • alvarob