UNPKG

always-helper

Version:

前端项目开发中,经常会用到一些工具函数的合集。

2 lines (1 loc) 172 B
var t=["","K","M","G","T"];export default function(r){if(r<=0)return"0";var o=Math.floor(Math.log(r)/Math.log(1024)),a=r/Math.pow(2,10*o);return Number(a.toFixed(2))+t[o]}