fliphub-monorepo
Version:
the builder of builders
85 lines (65 loc) • 1.7 kB
Markdown
//img.shields.io/npm/v/fliptime.svg
[ ]: https://npmjs.org/package/fliptime
[ ]: http://img.shields.io/badge/license-MIT-blue.svg?style=flat
[ ]: https://spdx.org/licenses/MIT
[ ]: https://img.shields.io/gitter/room/fliphub/pink.svg
[ ]: https://gitter.im/fliphub/Lobby
> fluent timer with laps, microtime + parsing, multiple timers
```bash
yarn add fliptime
npm i fliptime --save
```
```js
const timer = require('fliptime')
```
uses [microtime](https://github.com/wadey/node-microtime) formatted with [microseconds](https://github.com/kamicane/microseconds)
```js
timer.start('canada')
setTimeout(() => timer.end('canada').log('canada'), 500)
```
```js
timer.start('canada')
const lapper = setInterval(() => {
timer.lap('canada')
}, 1000)
setTimeout(() => clearInterval(lapper), 10000)
timer.logLaps('canada')
```
```js
timer.start('canada')
setTimeout(() => console.log(timer.end('canada').took('canada')), 500)
```
```js
const sleepfor = require('sleepfor')
timer.start('eh')
timer.start('canada')
sleepfor(100)
timer.lap('canada')
timer.stop('eh')
sleepfor(100)
timer.lap('canada')
timer
.stop('canada')
.log('eh')
.log('canada')
.logLaps('canada')
// second param is whether to use laps
const lapTime = timer.msTook('canada', true)
```
```js
timer.start('eh')
timer.stop('eh')
const microseconds = timer.took('eh')
const ms = timer.msTook('eh')
const parsed = timer.parsedTook()
```
[![NPM version][fliptime-image]][fliptime-url]
[![MIT License][license-image]][license-url]
[![fliphub][gitter-badge]][gitter-url]
[ ]: https: