https://github.com/brikcss/timer
Simple timer utility to start, stop, check duration, and clear a timer. Works in Node, JS/UMD modules, or the browser.
https://github.com/brikcss/timer
Last synced: about 2 months ago
JSON representation
Simple timer utility to start, stop, check duration, and clear a timer. Works in Node, JS/UMD modules, or the browser.
- Host: GitHub
- URL: https://github.com/brikcss/timer
- Owner: brikcss
- Created: 2018-03-27T03:04:30.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2018-11-08T20:44:18.000Z (over 6 years ago)
- Last Synced: 2025-03-15T08:18:05.385Z (3 months ago)
- Language: JavaScript
- Size: 95.7 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Timer
> Simple timer utility to start, stop, check duration, and clear a timer. Works in Node, JS/UMD modules, or the browser.
## Install
```sh
npm install @brikcss/timer --save-dev
```## Usage
**`timer.start(id)`**
Start a new or existing timer. Creates one if it doesn't exist. Returns the newly created timer object.
**`timer.stop(id)`**
Stop an existing timer. Returns the timer's duration as a string.
**`timer.duration(id)`**
Get the duration of a timer. Returns a string in `ms` or `s`.
**`timer.clear(id)`**
Clear / remove a timer from memory.
## Environment support
| Node | CLI | UMD | ES Module | Browser |
|:------:|:-----:|:-----:|:---------:|:---------:|
| ✔ | x | ✔ | ✔ | ✔ |