An open API service indexing awesome lists of open source software.

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: 6 months ago
JSON representation

Minimal time tracker.

Awesome Lists containing this project

README

        

# minimal-timer
> Keeps track of the elapsed time in miliseconds.

[![Build Status](https://travis-ci.org/AlvaroBernalG/minimal-timer.svg?branch=master)](https://travis-ci.org/AlvaroBernalG/minimal-timer) [![npm version](https://badge.fury.io/js/minimal-timer.svg)](https://badge.fury.io/js/minimal-timer) [![JavaScript Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](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/)