合集-常用代码块
摘要:# 极简版 randomColor() { return '#' + ('00000' + (Math.random() * 0x1000000 << 0).toString(16)).slice(-6); }
阅读全文
摘要:# Reduce 实现 const flatten = (target = [], level = Infinity) => target.reduce((total, current) => ( total.concat( (!Array.isArray(current) || level 0)
阅读全文
摘要:async function action(file) { const fileHash = await computedFileHash(file); const chunks = createChunks(file, { chunkSize: 1024 * 10, fileHash }); }
阅读全文
摘要:零、参考 最简实现Promise,支持异步链式调用(20行) 一、代码 function Promise(fn) { this.cbs = []; const resolve = (value) => { setTimeout(() => { this.data = value; this.cbs.
阅读全文