()
| 131 | } |
| 132 | |
| 133 | async 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 | |
| 164 | if (isMainThread) { |
| 165 | mainThread(); |
no test coverage detected