Perf: run cpu intensive task with worker

This commit is contained in:
SukkaW
2023-09-14 22:08:01 +08:00
parent b42bd05ccf
commit 2448cbe39a
6 changed files with 131 additions and 11 deletions

View File

@@ -30,5 +30,9 @@ const getGorhillPublicSuffix = async () => {
return gorhill;
};
const getGorhillPublicSuffixPromise = getGorhillPublicSuffix();
module.exports.getGorhillPublicSuffixPromise = getGorhillPublicSuffixPromise;
/** @type {Promise<import('gorhill-publicsuffixlist').default | null>} */
let gorhillPublicSuffixPromise = null;
module.exports.getGorhillPublicSuffixPromise = () => {
gorhillPublicSuffixPromise ||= getGorhillPublicSuffix();
return gorhillPublicSuffixPromise;
};

View File

@@ -10,10 +10,10 @@ module.exports.isDomainLoose = (domain) => {
};
/**
* @param {string} domain
* @param {string | null | undefined} domain
*/
module.exports.normalizeDomain = (domain) => {
if (domain == null) {
if (!domain) {
return null;
}