numerify
numerify 用来格式化值的一个工具,官方介绍This is a formatted value tool that makes formatting easier and more convenient to extend.
可以转数值类型,比如
Number Format String 10000 ‘0,0.0000’ 10,000.0000 10000.23 ‘0,0’ 10,000 10000.23 ‘+0,0’ +10,000 -10000 ‘0,0.0’ -10,000.0 10000.1234 ‘0.000’ 10000.123 100.1234 ‘00000’ 00100 1000.1234 ‘000000,0’ 001,000 10 ‘000.00’ 010.00 10000.1234 ‘0[.]00000’ 10000.12340 -10000 ‘(0,0.0000)’ (10,000.0000) -0.23 ‘.00’ -.23 -0.23 ‘(.00)’ (.23) 0.23 ‘0.00000’ 0.23000 0.23 ‘0.0[0000]’ 0.23 1230974 ‘0.0a’ 1.2m 1460 ‘0 a’ 1 k -104000 ‘0a’ -104k 1 ‘0%’ 100% 0.974878234 ‘0.000%’ 97.488% -0.43 ‘0 %’ -43 % 0.43 ‘(0.000 %)’ 43.000 %
调用的方法
numerify(number, formatter, roundFunction)
Plugins
bps
Number Format String 0 ‘0 BPS’ 0 BPS 0.0001 ‘0 BPS’ 1 BPS .0056 ‘0 BPS’ 56 BPS .25 ‘0BPS’ 2500BPS .000001 ‘0.00 BPS’ 0.01 BPS
bytes
Number Format String 100 ‘0b’ 100B 1024 ‘0b’ 1KB 2048 ‘0 ib’ 2 KiB 3072 ‘0.0 b’ 3.1 KB 7884486213 ‘0.00b’ 7.88GB 3467479682787 ‘0.000 ib’ 3.154 TiB
exponential
ordinal
time
Number Format String 25 ‘00:00:00’ 0:00:25 238 ‘00:00:00’ 0:03:58 63846 ‘00:00:00’ 17:44:06