mirror of
https://github.com/SukkaW/Surge.git
synced 2025-12-12 01:00:34 +08:00
Add ts-check to build script
This commit is contained in:
parent
a1cccf9c88
commit
9a307709a5
@ -1,3 +1,4 @@
|
||||
// @ts-check
|
||||
const { fetch } = require('undici');
|
||||
const fetchWithRetry = require('@vercel/fetch-retry')(fetch);
|
||||
module.exports.fetchWithRetry = fetchWithRetry;
|
||||
|
||||
@ -1,10 +1,16 @@
|
||||
// @ts-check
|
||||
const { parse } = require('tldts');
|
||||
|
||||
/**
|
||||
* @param {string} domain
|
||||
*/
|
||||
module.exports.isDomainLoose = (domain) => {
|
||||
const { isIcann, isPrivate, isIp } = parse(domain, { allowPrivateDomains: true });
|
||||
return !!(!isIp && (isIcann || isPrivate));
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {string} domain
|
||||
*/
|
||||
module.exports.normalizeDomain = (domain) => {
|
||||
if (domain == null) {
|
||||
return null;
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
// @ts-check
|
||||
const { fetchWithRetry } = require('./fetch-retry');
|
||||
const { NetworkFilter } = require('@cliqz/adblocker');
|
||||
const { normalizeDomain } = require('./is-domain-loose');
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
// @ts-check
|
||||
/** @type {[string, boolean][]} */
|
||||
const HOSTS = [
|
||||
['https://pgl.yoyo.org/adservers/serverlist.php?hostformat=hosts&showintro=0&mimetype=plaintext', true],
|
||||
|
||||
@ -1,5 +1,10 @@
|
||||
// @ts-check
|
||||
const { promises: fsPromises } = require('fs');
|
||||
|
||||
/**
|
||||
* @param {string[]} linesA
|
||||
* @param {string} filePath
|
||||
*/
|
||||
async function compareAndWriteFile(linesA, filePath) {
|
||||
const linesB = (await fsPromises.readFile(filePath, { encoding: 'utf-8' })).split('\n');
|
||||
|
||||
@ -14,6 +19,10 @@ async function compareAndWriteFile(linesA, filePath) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string[]} linesA
|
||||
* @param {string[]} linesB
|
||||
*/
|
||||
function stringArrayCompare (linesA, linesB) {
|
||||
if (linesA.length !== linesB.length) return false;
|
||||
|
||||
|
||||
@ -1,3 +1,5 @@
|
||||
// @ts-check
|
||||
|
||||
/**
|
||||
* @param {string} title
|
||||
* @param {string[]} description
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
// @ts-check
|
||||
const Piscina = require('piscina');
|
||||
// const { isCI } = require('ci-info');
|
||||
|
||||
@ -5,7 +6,9 @@ const fullsetDomainStartsWithADot = Piscina.workerData
|
||||
const totalLen = fullsetDomainStartsWithADot.length;
|
||||
|
||||
// const log = isCI ? () => { } : console.log.bind(console);
|
||||
|
||||
/**
|
||||
* @param {{ chunk: string[] }} param0
|
||||
*/
|
||||
module.exports = ({ chunk }) => {
|
||||
const chunkLength = chunk.length;
|
||||
const outputToBeRemoved = new Int8Array(chunkLength);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user