MCPcopy Create free account
hub / github.com/MCSManager/MCSManager / worker

Function worker

scripts/useless-key-scanner.mjs:133–162  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

131}
132
133async function worker() {
134 /** @type {Array<string>} */
135 const filesPath = workerData.filesPath;
136 /** @type {Map<string, boolean>} */
137 const langKeys = workerData.langKeys;
138
139 console.log("Create new thread ID:", threadId, "\tFiles:", filesPath.length);
140
141 async function readOneFile(filePath = "") {
142 const fileContent = await fs.promises.readFile(filePath, "utf-8");
143 for (const key of langKeys.keys()) {
144 if (fileContent.includes(key)) {
145 parentPort?.postMessage({
146 type: "key",
147 data: key
148 });
149 }
150 }
151 }
152
153 const promises = [];
154 for (const filePath of filesPath) {
155 promises.push(readOneFile(filePath));
156 }
157 await Promise.all(promises);
158 parentPort?.postMessage({
159 type: "exit",
160 data: threadId
161 });
162}
163
164if (isMainThread) {
165 mainThread();

Callers 1

Calls 3

readOneFileFunction · 0.85
logMethod · 0.80
pushMethod · 0.45

Tested by

no test coverage detected