boss-timer
Version:
Timer for node
46 lines (43 loc) • 1.21 kB
Markdown
# boss-timer
A very simple timer module for node js
## Install
```
npm install boss-timer
```
Add module to script
```js
var Timer = require('boss-timer')
```
## Creating a timer Object
```js
var my_timer = new Timer()
```
*Note* the timer will start as soon as you create the object to create a timer with out it start supply a false boolean argument when creating a timer
```js
var my_timer = new Timer(false)
```
# Functions
There are 4 functions on the timer, [start](#start), [stop](#stop), [split](#split), [elapsed](#elapse).
## <a name="start"></a> start()
This starts the timer is it has not already been started.
```js
my_timer.start()
```
## <a name="stop"></a> stop()
This stops the timer.
```js
my_timer.stop()
```
## <a name="split"></a> split()
Creates a split time in the time
```js
my_timer.split()
```
## <a name="elapsed"></a> elapsed(index?)
Returns the elapsed time on the timer or the elapsed time from the split index if supplied
```js
my_timer.elapsed() // gets the elapsed time
my_timer.elapsed(-1) // gets the elapsed time since the last split
my_timer.elapsed(2) // gets the time elapsed since the split time
//at the third index of the array
```