A zero dependencies high resolution timing function.
$ npm install @kikobeats/time-span --save
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
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