Perf/Refactor: processDomainList now returns string[]

This commit is contained in:
SukkaW
2024-05-26 17:27:11 +08:00
parent 816bb9ce2f
commit 21a31e6c1f
5 changed files with 50 additions and 26 deletions

View File

@@ -0,0 +1,26 @@
import { fetchRemoteTextByLine } from './fetch-text-by-line';
import { processLineFromReadline } from './process-line';
import { bench, group, run } from 'mitata';
(async () => {
const data = await processLineFromReadline(await fetchRemoteTextByLine('https://osint.digitalside.it/Threat-Intel/lists/latestdomains.txt'));
group('setAddFromArray', () => {
bench('run', () => {
const set = new Set(['1', '2', '1', '3', 'skk.moe']);
for (let i = 0, len = data.length; i < len; i++) {
set.add(data[i]);
}
});
});
group('setAddFromArray', () => {
bench('run', () => {
const set = new Set(['1', '2', '1', '3', 'skk.moe']);
// eslint-disable-next-line @typescript-eslint/unbound-method -- thisArg is passed
data.forEach(set.add, set);
});
});
run();
})();