Perf: speed up build

This commit is contained in:
SukkaW
2023-09-15 22:35:46 +08:00
parent 30cab8fc22
commit d5850aa84b
23 changed files with 241 additions and 184 deletions

View File

@@ -6,7 +6,7 @@
*
* @param {string} line
*/
module.exports.processLine = (line) => {
const processLine = (line) => {
if (!line) {
return null;
}
@@ -30,3 +30,19 @@ module.exports.processLine = (line) => {
return trimmed;
};
module.exports.processLine = processLine;
/**
* @param {import('readline').ReadLine} rl
*/
module.exports.processLineFromReadline = async (rl) => {
/** @type {string[]} */
const res = [];
for await (const line of rl) {
const l = processLine(line);
if (l) {
res.push(l);
}
}
return res;
};