# duck-timer

> A helpful timer class for both of browsers and node.js.

Latest version **1.0.3** (published 2022-04-05) · MIT license · 0 weekly downloads

## Install

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

## Health

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

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.3 |
| Published | 2022-04-05 |
| First published | 2017-11-04 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 110.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 3 |
| Author | archco |
| Maintainers | archco |
| Keywords | timer, countdown |

## Links

- npm: https://www.npmjs.com/package/duck-timer
- Repository: https://github.com/archco/duck-timer
- Homepage: https://github.com/archco/duck-timer#readme
- Issues: https://github.com/archco/duck-timer/issues
- npm.io page: https://npm.io/package/duck-timer

## Dependencies (1)

- [eventemitter3](https://npm.io/package/eventemitter3.md) ^4.0.7

## Recent versions

- 1.0.3 (latest) — 2022-04-05
- 1.0.2 — 2020-01-01
- 1.0.1 — 2019-12-17
- 1.0.0 — 2019-10-25
- 0.4.9 — 2018-08-14
- 0.4.8 — 2018-06-11
- 0.4.7 — 2018-05-18
- 0.4.6 — 2018-04-01
- 0.4.5 — 2018-03-13
- 0.4.4 — 2018-03-08
- 0.4.3 — 2018-03-08
- 0.4.2 — 2018-01-29
- 0.4.1 — 2018-01-28
- 0.4.0 — 2018-01-23
- 0.3.0 — 2017-11-07
- … 2 more at https://npm.io/package/duck-timer/versions

## README

# DuckTimer

[![Node.js CI](https://github.com/archco/duck-timer/actions/workflows/node.js.yml/badge.svg)](https://github.com/archco/duck-timer/actions/workflows/node.js.yml)
[![npm version](https://badge.fury.io/js/duck-timer.svg)](https://www.npmjs.com/package/duck-timer)
[![Downloads](https://img.shields.io/npm/dm/duck-timer.svg)](https://www.npmjs.com/package/duck-timer)

A helpful timer class for both of browsers and node.js.

## Installation

``` sh
npm install duck-timer
```

## Usage

### Stopwatch

``` js
import DuckTimer from 'duck-timer';
const timer = new DuckTimer({ interval: 100 }); // interval time: 100ms = 0.1sec.

// start.
timer.onInterval(res => {
  console.log(res.seconds);
}).start();

// stop.
timer.stop();

// reset.
timer.reset();
```

### Countdown

``` js
import DuckTimer from 'duck-timer';
const timer = new DuckTimer({ interval: 1000 });

timer.setCountdown(`Dec 25, ${new Date().getFullYear()}`)
  .onInterval(res => console.log(res.remain.seconds))
  .onTimeout(() => console.log('Merry Christmas!!!'))
  .start();
```

## API

Please see [DuckTimer API](https://github.com/archco/duck-timer/blob/master/doc/README.md).

## License

[MIT License](https://github.com/archco/duck-timer/blob/master/LICENSE)

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