-
Notifications
You must be signed in to change notification settings - Fork 15
/
folder.js
31 lines (25 loc) · 909 Bytes
/
folder.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
/* eslint-disable */
const fs = require('node:fs/promises');
const path = require('node:path');
const { NodeAdapterReedSolomon } = require('../dist/node.adapter');
const rs = new NodeAdapterReedSolomon();
const folderPath = './dist';
(async () => {
async function traverse(currentPath) {
console.time('total');
const files = await fs.readdir(currentPath);
for (let i = 0; i < files.length; i++) {
const file = files[i];
const filePath = path.join(currentPath, file);
const stat = await fs.stat(filePath);
console.time('file', file);
const fileBuffer = await fs.readFile(filePath);
const res = await rs.encodeInWorker(__filename, Uint8Array.from(fileBuffer));
console.timeEnd('file');
console.log(file, 'res: ', res);
}
console.log('files count: ', files.length);
console.timeEnd('total');
}
await traverse(folderPath);
})();