mirror of
https://github.com/SukkaW/Surge.git
synced 2025-12-21 13:50:29 +08:00
54 lines
2.4 KiB
JavaScript
54 lines
2.4 KiB
JavaScript
'use strict';Object.defineProperty(exports,Symbol.toStringTag,{value:'Module'});const validateHashCollisionTest=require('../_virtual/validate-hash-collision-test.cjs'),require$$5=require('fdir'),dir=require('./constants/dir.cjs'),require$$0=require('node:path'),fetchTextByLine=require('./lib/fetch-text-by-line.cjs'),require$$4=require('hash-wasm');/* eslint-disable no-await-in-loop -- no concurrent */
|
|
|
|
var hasRequiredValidateHashCollisionTest;
|
|
|
|
function requireValidateHashCollisionTest () {
|
|
if (hasRequiredValidateHashCollisionTest) return validateHashCollisionTest.__exports;
|
|
hasRequiredValidateHashCollisionTest = 1;
|
|
Object.defineProperty(validateHashCollisionTest.__exports, "__esModule", {
|
|
value: true
|
|
});
|
|
const _fdir = require$$5;
|
|
const _dir = /*@__PURE__*/ dir.__require();
|
|
const _nodepath = /*#__PURE__*/ _interop_require_default(require$$0);
|
|
const _fetchtextbyline = /*@__PURE__*/ fetchTextByLine.__require();
|
|
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.__exports;
|
|
}exports.__require=requireValidateHashCollisionTest; |