# timer-stopwatch

> A stopwatch and countdown timer for node

Latest version **0.2.0** (published 2015-12-02) · 0 weekly downloads

## Install

```sh
npm install timer-stopwatch
pnpm add timer-stopwatch
yarn add timer-stopwatch
bun add timer-stopwatch
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.2.0 |
| Published | 2015-12-02 |
| First published | 2014-07-08 |
| Weekly downloads | 0 |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Known vulnerabilities | 0 (+5 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 45 |
| Author | Mick Crozier |
| Maintainers | mickcrozier |
| Keywords | timer, stopwatch, clock, countdown |

## Links

- npm: https://www.npmjs.com/package/timer-stopwatch
- Repository: https://github.com/MickCrozier/timer-stopwatch
- Issues: https://github.com/MickCrozier/timer-stopwatch/issues
- npm.io page: https://npm.io/package/timer-stopwatch

## Dependencies (1)

- [lodash](https://npm.io/package/lodash.md) ^2.4.1

## Recent versions

- 0.2.0 (latest) — 2015-12-02
- 0.1.7 — 2015-12-01
- 0.1.6 — 2015-06-04
- 0.1.5 — 2014-07-18
- 0.1.4 — 2014-07-16
- 0.1.3 — 2014-07-16
- 0.1.2 — 2014-07-15
- 0.1.1 — 2014-07-13
- 0.1.0 — 2014-07-08

## README

timer-stopwatch [![Codeship Status for MickCrozier/timer-stopwatch](https://codeship.io/projects/d68910a0-e989-0131-eba0-368dc75eab9e/status)](https://codeship.io/projects/26196)
========================

A stopwatch and countdown clock module for node.js


Install
======

```shell
npm install timer-stopwatch
```


How to
======
**The Gist**
new Stopwatch([countDownMS], [options])


Basic timers
```js
var Stopwatch = require('timer-stopwatch');

var timer = new Stopwatch(60000); // A new countdown timer with 60 seconds
var stopwatch = new Stopwatch(); // A new count up stopwatch. Starts at 0.
```

###Event Methods
```js
// Fires every 50ms by default. Change setting the 'refreshRateMS' options
timer.onTime(function(time) {
	console.log(time.ms); // number of milliseconds past (or remaining);
});

// Fires when the timer is done
timer.onDone(function(){
	console.log('Timer is complete');
});

// Fires when the timer is almost complete - default is 10 seconds remaining. Change with 'almostDoneMS' option
timer.onAlmostdone(function() {
	console.log('Timer is almost complete');
});

//These methods are chainable
timer.onTime(cb).onAlmostdone(cb).onDone(cb);

```

###Timer Methods
```js
timer.start();
timer.stop();
timer.startstop();        // Toggles the running state
timer.reset(countDownMS); // optional countDownMS to reset countdown to that many milliseconds
```

###Properties
```js
timer.ms;		// Number of milliseconds on the clock
```



###Options
```js
var options = {
	refreshRateMS: 10,		// How often the clock should be updated
	almostDoneMS: 10000, 	// When counting down - this event will fire with this many milliseconds remaining on the clock
}

var timer = new Stopwatch(60000, options);
```

Breaking Changes in v0.2
======

- The 'forcestop' event is being depreciated in favour of 'stop'.
- Use the onTime, onAlmostDone, onDone and onStop methods in favour of .on('eventname').

Testing
======

Unit and Integration tests (requires dev dependencies)
```shell
npm test
```

License
======
MIT License

---
_Source: https://npm.io/package/timer-stopwatch · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
