bruce-millis-option
Convert various time formats to milliseconds and throw if result is NaN
. Like bruce-millis
but dies harder.
Usage
const ms = // 24 // 5000 // 60000 // 7200000 // 9000000 // 36000000 // 86400000 // 172800000 // 31557600000 // -259200000 // -3600000 // throws TypeError
API
ms(value[, hint])
Parses value
with bruce-millis
, throws a TypeError if result is NaN
. A hint
may be provided to customize the error message:
$ node example.js
/example/node_modules/bruce-millis-option/index.js:11
throw new TypeError(
^
TypeError: The timeout option must be a number in milliseconds or a string with unit (e.g. '5m')
at module.exports (/example/node_modules/bruce-millis-option/index.js:11:11)
at Object.<anonymous> (/example/example.js:2:1)
at ..
Install
With npm do:
npm install bruce-millis-option
License
MIT © 2020-present Vincent Weevers