See how long a function takes to run
import { time } from "@rjweb/utils"
const [ time, result ] = time.fn(async() => {
await time.wait(time(20).s())
})
console.log(time, result) // 20000 undefined
1.5.3
nodejs, browser
Parse a time string into milliseconds
import { time } from "@rjweb/utils"
time.parse('2s') // 2000
time.parse('2m 30 s') // 150000
time.parse('2h 30minute 30s') // 9030000
time.parse('2day 3minute 30h 30s 4 ms') // 183810004
time.parse('Jan 2 2022') // <will depend on current date>
time.parse('1w -1d') // 518400000
time.parse('1d -12h') // 43200000
time.parse('hi') // null
1.12.8
nodejs, browser
Utility for defining milliseconds