1.0.5 • Published 8 months ago
@kikobeats/time-span v1.0.5
time-span
A zero dependencies high resolution timing function.
Install
$ npm install @kikobeats/time-span --save
Usage
const { setTimeout } = require('timers/promises')
const timeSpan = require('@kikobeats/time-span')()
const duration = timeSpan()
await setTimeout(5000)
console.log(duration()) // => 5001.870375
It also accepts a format
function:
const timeSpan = require('@kikobeats/time-span')({
format: n => `${Math.round(n)}ms`
})
const duration = timeSpan()
await setTimeout(5000)
console.log(duration()) // => 5000ms
License
time-span © Kiko Beats, released under the MIT License. Authored and maintained by Kiko Beats with help from contributors.
kikobeats.com · GitHub Kiko Beats · Twitter @Kikobeats