@ifraan_/pretty-ms
v1.0.4
Published
Transform milliseconds to reading time.
Downloads
12
Maintainers
Readme
To install use:
npm i @ifraan_/pretty-ms
Examples:
Default
const value = (1003 * 90 * 5 * 10 * 305) - 36000; // random ms
prettyMs(value)
// '15d 22h 23m 1s'
prettyMs(value, { verbose: true })
// '15 days, 22 hours, 23 minutes and 1 second'
Compact
const value = (1003 * 90 * 5 * 10 * 305) - 36000; // random ms
prettyMs(value, { compact: true })
// '15d'
prettyMs(value, { compact: true, verbose: true })
// '15 days'
prettyMs(value, { compact: true, colonNotation: true })
// '15:22:23:01'
Sub Milliseconds
const value = (1000 * 60) + 1500.660005; // random ms
prettyMs(value, { formatSubMilliseconds: true })
// '1m 1s 500ms 660µs 5ns'
prettyMs(value, { formatSubMilliseconds: true, verbose: true })
// '1 minute, 1 second, 500 milliseconds, 660 microseconds and 5 nanoseconds'
Multiple languages
prettyMs(value, { verbose: true, lang: 'en' }); // english
// '15 days, 22 hours, 23 minutes and 1 second'
prettyMs(value, { verbose: true, lang: 'es' }); // spanish
// '15 días, 22 horas, 23 minutos y 1 segundo'
prettyMs(value, { verbose: true, lang: 'pt' }); // portuguese
// '15 dias, 22 horas, 23 minutos e 1 segundo'