https://github.com/alvarobernalg/minimal-timer
Minimal time tracker.
https://github.com/alvarobernalg/minimal-timer
chronometer elapsedtime miliseconds stopwatch time timer track tracker
Last synced: 10 months ago
JSON representation
Minimal time tracker.
- Host: GitHub
- URL: https://github.com/alvarobernalg/minimal-timer
- Owner: AlvaroBernalG
- Created: 2017-07-03T20:02:33.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2017-07-07T10:26:54.000Z (almost 9 years ago)
- Last Synced: 2025-05-27T08:21:10.965Z (about 1 year ago)
- Topics: chronometer, elapsedtime, miliseconds, stopwatch, time, timer, track, tracker
- Language: JavaScript
- Homepage:
- Size: 58.6 KB
- Stars: 3
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
Awesome Lists containing this project
README
# minimal-timer
> Keeps track of the elapsed time in miliseconds.
[](https://travis-ci.org/AlvaroBernalG/minimal-timer) [](https://badge.fury.io/js/minimal-timer) [](https://standardjs.com)
## Install
```
$ npm install minimal-timer --save
```
## Usage
```js
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](https://github.com/AlvaroBernalG/)