mirror of
https://github.com/SukkaW/Surge.git
synced 2025-12-21 13:50:29 +08:00
55 lines
2.6 KiB
JavaScript
55 lines
2.6 KiB
JavaScript
'use strict';const fetchRetry=require('./chunks/fetch-retry.D06uBUaW.cjs'),require$$5=require('fdir'),require$$0=require('node:path'),fetchTextByLine=require('./chunks/fetch-text-by-line.YY5b5610.cjs'),require$$4=require('hash-wasm');require('picocolors'),require('undici'),require('undici-cache-store-better-sqlite3'),require('node:util'),require('node:fs'),require('node:process'),require('node:readline'),require('node:stream/web'),require('foxts/guard');var validateHashCollisionTest$1 = {};/* eslint-disable no-await-in-loop -- no concurrent */
|
|
|
|
var hasRequiredValidateHashCollisionTest;
|
|
|
|
function requireValidateHashCollisionTest () {
|
|
if (hasRequiredValidateHashCollisionTest) return validateHashCollisionTest$1;
|
|
hasRequiredValidateHashCollisionTest = 1;
|
|
Object.defineProperty(validateHashCollisionTest$1, "__esModule", {
|
|
value: true
|
|
});
|
|
const _fdir = require$$5;
|
|
const _dir = /*@__PURE__*/ fetchRetry.a();
|
|
const _nodepath = /*#__PURE__*/ _interop_require_default(require$$0);
|
|
const _fetchtextbyline = /*@__PURE__*/ fetchTextByLine.a();
|
|
const _hashwasm = require$$4;
|
|
function _interop_require_default(obj) {
|
|
return obj && obj.__esModule ? obj : {
|
|
default: obj
|
|
};
|
|
}
|
|
(async ()=>{
|
|
const hashMap = new Map();
|
|
const runHash = async (inputs)=>{
|
|
for (const input of inputs){
|
|
const hash = await (0, _hashwasm.xxhash3)(input);
|
|
if (!hashMap.has(hash)) {
|
|
hashMap.set(hash, new Set());
|
|
}
|
|
hashMap.get(hash).add(input);
|
|
}
|
|
};
|
|
const files = await new _fdir.fdir().withRelativePaths().crawl(_dir.OUTPUT_SURGE_DIR).withPromise();
|
|
for (const file of files){
|
|
const fullpath = _nodepath.default.join(_dir.OUTPUT_SURGE_DIR, file);
|
|
if (file.startsWith('domainset' + _nodepath.default.sep)) {
|
|
await runHash((await (0, _fetchtextbyline.readFileIntoProcessedArray)(fullpath)).map((i)=>i[0] === '.' ? i.slice(1) : i));
|
|
} else if (file.startsWith('non_ip' + _nodepath.default.sep)) {
|
|
await runHash((await (0, _fetchtextbyline.readFileIntoProcessedArray)(fullpath)).map((i)=>i.split(',')[1]));
|
|
}
|
|
}
|
|
console.log(hashMap.size);
|
|
let collision = 0;
|
|
hashMap.forEach((v, k)=>{
|
|
if (v.size > 1) {
|
|
collision++;
|
|
console.log(k, '=>', v);
|
|
}
|
|
});
|
|
if (collision === 0) {
|
|
console.log(hashMap);
|
|
}
|
|
})();
|
|
return validateHashCollisionTest$1;
|
|
}var validateHashCollisionTestExports = requireValidateHashCollisionTest();
|
|
const validateHashCollisionTest = /*@__PURE__*/fetchRetry.g(validateHashCollisionTestExports);module.exports=validateHashCollisionTest; |