Chore: more refactor to the bun

This commit is contained in:
SukkaW
2023-11-15 15:20:37 +08:00
parent 37257958c2
commit 071b8120a6
36 changed files with 200 additions and 250 deletions

35
Build/lib/process-line.ts Normal file
View File

@@ -0,0 +1,35 @@
export const processLine = (line: string): string | null => {
if (!line) {
return null;
}
const line_0: string = line[0];
if (
line_0 === '#'
|| line_0 === ' '
|| line_0 === '\r'
|| line_0 === '\n'
|| line_0 === '!'
) {
return null;
}
const trimmed: string = line.trim();
if (trimmed === '') {
return null;
}
return trimmed;
};
export const processLineFromReadline = async (rl: AsyncGenerator<string>): Promise<string[]> => {
const res: string[] = [];
for await (const line of rl) {
const l: string | null = processLine(line);
if (l) {
res.push(l);
}
}
return res;
};