This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| async function asyncPool(concurrency, iterable, iteratorFn) { | |
| const ret = []; // Store all asynchronous tasks | |
| const executing = new Set(); // Stores executing asynchronous tasks | |
| for (const item of iterable) { | |
| // Call the iteratorFn function to create an asynchronous task | |
| const p = Promise.resolve().then(() => iteratorFn(item, iterable)); | |
| ret.push(p); // save new async task | |
| executing.add(p); // Save an executing asynchronous task | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function asyncPool(concurrency, iterable, iteratorFn) { | |
| let i = 0; | |
| const ret = []; // // Store all asynchronous tasks | |
| const executing = new Set(); // Stores executing asynchronous tasks | |
| const enqueue = function() { | |
| if (i === iterable.length) { | |
| return Promise.resolve(); | |
| } | |
| const item = iterable[i++]; // Get the new task item | |
| const p = Promise.resolve().then(() => iteratorFn(item, iterable)); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <!DOCTYPE html> | |
| <html lang="en"> | |
| <head> | |
| <meta charset="UTF-8"> | |
| <meta http-equiv="X-UA-Compatible" content="IE=edge"> | |
| <meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
| <title>File Type Detect Demo</title> | |
| </head> | |
| <body> | |
| <div> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <!DOCTYPE html> | |
| <html lang="zh-cn"> | |
| <head> | |
| <meta charset="UTF-8" /> | |
| <meta http-equiv="X-UA-Compatible" content="IE=edge" /> | |
| <meta name="viewport" content="width=device-width, initial-scale=1.0" /> | |
| <title>Transmat Source 示例</title> | |
| <script src="https://unpkg.com/transmat/lib/index.umd.js"></script> | |
| <style> | |
| body { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <!DOCTYPE html> | |
| <html lang="zh-CN"> | |
| <head> | |
| <meta charset="UTF-8" /> | |
| <meta name="viewport" content="width=device-width, initial-scale=1.0" /> | |
| <meta http-equiv="X-UA-Compatible" content="ie=edge" /> | |
| <title>大文件并发上传示例(阿宝哥)</title> | |
| <script src="https://cdn.bootcdn.net/ajax/libs/axios/0.21.1/axios.min.js"></script> | |
| <script src="https://cdn.bootcdn.net/ajax/libs/spark-md5/3.0.0/spark-md5.min.js"></script> | |
| </head> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const path = require("path"); | |
| const Koa = require("koa"); | |
| const cors = require("@koa/cors"); | |
| const multer = require("@koa/multer"); | |
| const Router = require("@koa/router"); | |
| const fse = require("fs-extra"); | |
| const app = new Koa(); | |
| const router = new Router(); | |
| const paths = path.sep + ["public", "upload"].join(path.sep); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const path = require("path"); | |
| const Koa = require("koa"); | |
| const cors = require("@koa/cors"); | |
| const Router = require("@koa/router"); | |
| const StreamZip = require("node-stream-zip"); | |
| const app = new Koa(); | |
| const router = new Router(); | |
| const ZIP_HOME = path.join(__dirname, "zip"); | |
| const UnzipCaches = new Map(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <!DOCTYPE html> | |
| <html lang="zh-cn"> | |
| <head> | |
| <meta charset="UTF-8" /> | |
| <meta http-equiv="X-UA-Compatible" content="IE=edge" /> | |
| <meta name="viewport" content="width=device-width, initial-scale=1.0" /> | |
| <title>多线程下载示例</title> | |
| <script src="multi-thread-download.js"></script> | |
| </head> | |
| <body> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <!DOCTYPE html> | |
| <html lang="zh-cn"> | |
| <head> | |
| <meta charset="UTF-8" /> | |
| <meta http-equiv="X-UA-Compatible" content="IE=edge" /> | |
| <meta name="viewport" content="width=device-width, initial-scale=1.0" /> | |
| <title>Axios 请求重试示例(适配器)</title> | |
| <script src="https://cdn.bootcdn.net/ajax/libs/axios/0.21.1/axios.min.js"></script> | |
| </head> | |
| <body> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <!DOCTYPE html> | |
| <html lang="zh-cn"> | |
| <head> | |
| <meta charset="UTF-8" /> | |
| <meta http-equiv="X-UA-Compatible" content="IE=edge" /> | |
| <meta name="viewport" content="width=device-width, initial-scale=1.0" /> | |
| <title>Axios 缓存请求数据示例</title> | |
| <script src="https://cdn.bootcdn.net/ajax/libs/qs/6.9.6/qs.min.js"></script> | |
| <script src="https://cdn.bootcdn.net/ajax/libs/axios/0.21.1/axios.min.js"></script> | |
| </head> |