4.1.0 • Published 7 years ago

minimal-timer v4.1.0

Weekly downloads
1
License
M.I.T
Repository
github
Last release
7 years ago

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(customStartDateoptional) 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

4.1.0

7 years ago

4.0.0

7 years ago

3.3.0

7 years ago

3.2.0

7 years ago

3.1.0

7 years ago

3.0.0

7 years ago

2.2.0

7 years ago

2.1.0

7 years ago

2.0.0

7 years ago

1.6.0

7 years ago

1.5.0

7 years ago

1.0.0

7 years ago

0.2.0

7 years ago

0.1.0

7 years ago