工具函数
amy1019
这个作者很懒,什么都没留下…
展开
-
轮询工具函数
let taskList = [] let map = new Map() let id = 0 function delay (t) { return new Promise(resolve => setTimeout(resolve, t)) } // 循环体中,储存完数据后最终及时销毁,避免造成内存泄漏 async function run (id, handler, timegap) { while (taskList.indexOf(id) > -1) { ..原创 2021-09-24 17:13:06 · 132 阅读 · 0 评论 -
工具函数积累
格式化文件大小 function formatBytes (bytes, decimals = 2) { if (bytes === 0) return '0 Bytes' const k = 1024 const dm = decimals < 0 ? 0 : decimals const sizes = ['Bytes', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'] const i = Math.floor(Math.lo原创 2021-08-24 18:55:40 · 56 阅读 · 0 评论