合集-常用代码块

摘要:# 极简版 randomColor() { return '#' + ('00000' + (Math.random() * 0x1000000 << 0).toString(16)).slice(-6); } 阅读全文
posted @ 2024-03-28 16:56 shiweiqianju 阅读(3) 评论(0) 推荐(0) 编辑
摘要:# Reduce 实现 const flatten = (target = [], level = Infinity) => target.reduce((total, current) => ( total.concat( (!Array.isArray(current) || level 0) 阅读全文
posted @ 2024-03-28 17:02 shiweiqianju 阅读(4) 评论(0) 推荐(0) 编辑
摘要:async function action(file) { const fileHash = await computedFileHash(file); const chunks = createChunks(file, { chunkSize: 1024 * 10, fileHash }); } 阅读全文
posted @ 2024-03-28 17:03 shiweiqianju 阅读(3) 评论(0) 推荐(0) 编辑
摘要:零、参考 最简实现Promise,支持异步链式调用(20行) 一、代码 function Promise(fn) { this.cbs = []; const resolve = (value) => { setTimeout(() => { this.data = value; this.cbs. 阅读全文
posted @ 2024-05-16 14:13 shiweiqianju 阅读(2) 评论(0) 推荐(0) 编辑

点击右上角即可分享
微信分享提示