[github地点:https://github.com/ABCDdouyae…]
pretty-ms
将毫秒转换为轻易读取的时候:1337000000 → 15d 11h 23m 20s
一般用法
用法
:prettyMs(milliseconds)
返回
:string
第二参数用法
用法
:prettyMs(milliseconds, options|object)
返回
:string
- secDecimalDigits:秒数背面保存的小数点位数,默许1
prettyMs(21312, {secDecimalDigits: 2});//21.32s
- msDecimalDigits:毫秒背面保存的小数点位数,默许0,与process.hrtime()连系运用
- keepDecimalsOnWholeSeconds:保证输出的秒数宽度稳定,默许false
prettyMs(20000, {keepDecimalsOnWholeSeconds: true });
//20.0s
- compact:仅展现第一个单元的值,默许false
prettyMs(123232, {compact: true});//~2m
- unitCount:要展现的单元个数,compact为true会掩盖此选项,默许:infinity
prettyMs(12312312, {unitCount: 2})//~3h 25m
- verbose:运用全拼的单元,默许false
prettyMs(12312312, {verbose: true});
// 3 hours 25 minutes 12.3 seconds
- separateMs:最小单元为毫秒数,默许false
prettyMs(12312312, {separateMs: true});// 3h 25m 12s 312ms
- formatSubMs: 显现微秒和纳秒部份,默许false
prettyMs(12312312.12323, {formatSubMs: true});//3h 25m 12s 312ms 123µs 230ns
prettyMs(12312312.12323, {formatSubMs: true, verbose: true});
//3 3 hours 25 minutes 12 seconds 312 milliseconds 123 microseconds 230 nanoseconds