mirror of
https://github.com/SukkaW/Surge.git
synced 2026-09-12 10:34:35 +08:00
Housekeeping & Make ESLint Happy
This commit is contained in:
@@ -265,7 +265,8 @@ function parseArguments(args: string[]) {
|
||||
let modes: BenchmarkMode[] = ['fetch', 'request'];
|
||||
const urls: string[] = [];
|
||||
|
||||
for (const arg of args) {
|
||||
for (let i = 0, len = args.length; i < len; i++) {
|
||||
const arg = args[i];
|
||||
if (arg === '--') {
|
||||
continue;
|
||||
}
|
||||
@@ -334,7 +335,8 @@ async function main() {
|
||||
// Use fresh Agents and discard both results. This primes shared DNS/CDN
|
||||
// state and initializes both APIs without carrying HTTP connections into
|
||||
// measured rounds.
|
||||
for (const mode of modes) {
|
||||
for (let i = 0, len = modes.length; i < len; i++) {
|
||||
const mode = modes[i];
|
||||
// eslint-disable-next-line no-await-in-loop -- warm-up is intentionally isolated per mode
|
||||
await runMode(mode, urls, concurrency, encoding, 'warmup', false);
|
||||
}
|
||||
@@ -347,14 +349,16 @@ async function main() {
|
||||
// later in the trial.
|
||||
const roundModes = round % 2 === 0 ? modes.toReversed() : modes;
|
||||
console.log('[download benchmark:round]', `round=${round}`, `order=${roundModes.join(',')}`);
|
||||
for (const mode of roundModes) {
|
||||
for (let i = 0, len = roundModes.length; i < len; i++) {
|
||||
const mode = roundModes[i];
|
||||
// eslint-disable-next-line no-await-in-loop -- modes intentionally run separately for comparable totals
|
||||
const result = await runMode(mode, urls, concurrency, encoding, round);
|
||||
results.get(mode)?.push(result);
|
||||
}
|
||||
}
|
||||
|
||||
for (const mode of modes) {
|
||||
for (let i = 0, len = modes.length; i < len; i++) {
|
||||
const mode = modes[i];
|
||||
printModeSummary(mode, results.get(mode) ?? []);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,7 +35,8 @@ export const buildDeprecateFiles = task(require.main === module, __filename)((sp
|
||||
|
||||
appendArrayInPlace(promises, REMOVED_FOLDERS.map(folder => fsp.rm(path.join(PUBLIC_DIR, folder), { force: true, recursive: true })));
|
||||
|
||||
for (const [filePath, description] of DEPRECATED_FILES) {
|
||||
for (let i = 0, len = DEPRECATED_FILES.length; i < len; i++) {
|
||||
const [filePath, description] = DEPRECATED_FILES[i];
|
||||
const content = [
|
||||
'#########################################',
|
||||
'# Sukka\'s Ruleset - Deprecated',
|
||||
|
||||
@@ -73,7 +73,8 @@ export const buildAlwaysRealIPModule = task(require.main === module, __filename)
|
||||
|
||||
const getDnsMappingRuleWithoutWildcard = createGetDnsMappingRule(false);
|
||||
|
||||
for (const { domains } of dataset) {
|
||||
for (let i = 0, len = dataset.length; i < len; i++) {
|
||||
const { domains } = dataset[i];
|
||||
clashFakeIpFilter.addFromRuleset(domains.flatMap(getDnsMappingRuleWithoutWildcard));
|
||||
}
|
||||
|
||||
|
||||
@@ -71,7 +71,8 @@ export class AdGuardHome extends BaseWriteStrategy {
|
||||
// So we can't do noResolve
|
||||
return;
|
||||
}
|
||||
for (const ipcidr of ipGroup) {
|
||||
for (let i = 0, len = ipGroup.length; i < len; i++) {
|
||||
const ipcidr = ipGroup[i];
|
||||
if (ipcidr.endsWith('/32')) {
|
||||
this.result.push(`||${ipcidr.slice(0, -3)}`);
|
||||
/* else if (ipcidr.endsWith('.0/24')) {
|
||||
@@ -89,7 +90,8 @@ export class AdGuardHome extends BaseWriteStrategy {
|
||||
// So we can't do noResolve
|
||||
return;
|
||||
}
|
||||
for (const ipcidr of ipGroup) {
|
||||
for (let i = 0, len = ipGroup.length; i < len; i++) {
|
||||
const ipcidr = ipGroup[i];
|
||||
if (ipcidr.endsWith('/128')) {
|
||||
this.result.push(`||${ipcidr.slice(0, -4)}`);
|
||||
} else {
|
||||
|
||||
@@ -231,7 +231,7 @@ export class SurgeMitmSgmodule extends BaseWriteStrategy {
|
||||
return newCombinations;
|
||||
};
|
||||
|
||||
for (let i = 0; i < matches.length; i++) {
|
||||
for (let i = 0, len = matches.length; i < len; i++) {
|
||||
const match = matches[i];
|
||||
const [_, ...options] = match;
|
||||
|
||||
@@ -245,8 +245,10 @@ export class SurgeMitmSgmodule extends BaseWriteStrategy {
|
||||
});
|
||||
}
|
||||
|
||||
for (const i of urlRegexResults) {
|
||||
for (const processed of i.processed) {
|
||||
for (let i = 0, len = urlRegexResults.length; i < len; i++) {
|
||||
const result = urlRegexResults[i];
|
||||
for (let j = 0, len2 = result.processed.length; j < len2; j++) {
|
||||
const processed = result.processed[j];
|
||||
if (
|
||||
normalizeDomain(
|
||||
processed
|
||||
@@ -254,9 +256,9 @@ export class SurgeMitmSgmodule extends BaseWriteStrategy {
|
||||
.replaceAll('?', 'b')
|
||||
)
|
||||
) {
|
||||
parsed.push([i.origin, processed]);
|
||||
parsed.push([result.origin, processed]);
|
||||
} else if (!isProbablyIpv4(processed)) {
|
||||
parsedFailures.push([i.origin, processed]);
|
||||
parsedFailures.push([result.origin, processed]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -201,7 +201,8 @@ function mergeWorkerTrace(
|
||||
workerTimeOrigin: number
|
||||
): void {
|
||||
const offset = workerTimeOrigin - performance.timeOrigin;
|
||||
for (const child of workerTraceResult.children) {
|
||||
for (let i = 0, len = workerTraceResult.children.length; i < len; i++) {
|
||||
const child = workerTraceResult.children[i];
|
||||
parentSpan.traceResult.children.push(adjustTraceTimestamps(child, offset));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -71,7 +71,8 @@ function writeJobSummary(shardLabel: string, dead: string[], geo: RunnerGeoIP |
|
||||
const bar = new cliProgress.SingleBar({}, cliProgress.Presets.shades_classic);
|
||||
bar.start(shardDomains.length, 0);
|
||||
|
||||
for (const { domain, includeAllSubdomain } of shardDomains) {
|
||||
for (let i = 0, len = shardDomains.length; i < len; i++) {
|
||||
const { domain, includeAllSubdomain } = shardDomains[i];
|
||||
queue.add(async () => {
|
||||
let registerableDomainAlive, registerableDomain, alive: boolean | undefined;
|
||||
|
||||
|
||||
@@ -70,7 +70,9 @@ export async function parseGfwList() {
|
||||
]);
|
||||
|
||||
const text = await (await $$fetch('https://raw.githubusercontent.com/gfwlist/gfwlist/master/gfwlist.txt')).text();
|
||||
for (const l of atob(text).split('\n')) {
|
||||
const lines = atob(text).split('\n');
|
||||
for (let i = 0, len = lines.length; i < len; i++) {
|
||||
const l = lines[i];
|
||||
const line = processLine(l);
|
||||
if (!line) continue;
|
||||
|
||||
|
||||
@@ -9,7 +9,8 @@ import { xxhash3 } from 'hash-wasm';
|
||||
const hashMap = new Map<string, Set<string>>();
|
||||
|
||||
const runHash = async (inputs: string[]) => {
|
||||
for (const input of inputs) {
|
||||
for (let i = 0, len = inputs.length; i < len; i++) {
|
||||
const input = inputs[i];
|
||||
const hash = await xxhash3(input);
|
||||
if (!hashMap.has(hash)) {
|
||||
hashMap.set(hash, new Set());
|
||||
@@ -23,7 +24,8 @@ import { xxhash3 } from 'hash-wasm';
|
||||
.crawl(OUTPUT_SURGE_DIR)
|
||||
.withPromise();
|
||||
|
||||
for (const file of files) {
|
||||
for (let i = 0, len = files.length; i < len; i++) {
|
||||
const file = files[i];
|
||||
const fullpath = path.join(OUTPUT_SURGE_DIR, file);
|
||||
if (file.startsWith('domainset' + path.sep)) {
|
||||
await runHash((await readFileIntoProcessedArray(fullpath)).map(i => (i[0] === '.' ? i.slice(1) : i)));
|
||||
|
||||
Reference in New Issue
Block a user