Refactor: drop Bun.inspect and Bun.version

This commit is contained in:
SukkaW
2024-07-23 16:33:58 +08:00
parent fd6429e2aa
commit 1f42c27afe
5 changed files with 21 additions and 11 deletions

View File

@@ -69,13 +69,12 @@ export function fetchRemoteTextByLine(url: string | URL) {
return fetchWithRetry(url, defaultRequestInit).then(createReadlineInterfaceFromResponse);
}
export async function readFileIntoProcessedArray(file: string | URL | BunFile) {
if (typeof file === 'string') {
file = Bun.file(file);
} else if (!('writer' in file)) {
file = Bun.file(file);
export async function readFileIntoProcessedArray(file: string | BunFile | FileHandle) {
const results = [];
for await (const line of readFileByLine(file)) {
if (processLine(line)) {
results.push(line);
}
}
const content = await file.text();
return content.split('\n').filter(processLine);
return results;
}