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;
};