Move TextLineStream to foxts, adopt skipEmptyLines
Some checks failed
Build / Build (push) Has been cancelled
Build / Diff output (push) Has been cancelled
Build / Deploy to Cloudflare Pages (push) Has been cancelled
Build / Deploy to GitHub and GitLab (push) Has been cancelled

This commit is contained in:
SukkaW
2025-03-11 01:05:14 +08:00
parent ac200f67c5
commit c9ebec077f
3 changed files with 4 additions and 84 deletions

View File

@@ -2,7 +2,7 @@ import picocolors from 'picocolors';
import { $$fetch, defaultRequestInit, ResponseError } from './fetch-retry';
import { waitWithAbort } from 'foxts/wait';
import { nullthrow } from 'foxts/guard';
import { TextLineStream } from './text-line-transform-stream';
import { TextLineStream } from 'foxts/text-line-stream';
import { ProcessLineStream } from './process-line';
// eslint-disable-next-line sukka/unicorn/custom-error-definition -- typescript is better
@@ -32,7 +32,7 @@ export async function fetchAssets(url: string, fallbackUrls: null | undefined |
}
const res = await $$fetch(url, { signal: controller.signal, ...defaultRequestInit });
let stream = nullthrow(res.body, url + ' has an empty body').pipeThrough(new TextDecoderStream()).pipeThrough(new TextLineStream());
let stream = nullthrow(res.body, url + ' has an empty body').pipeThrough(new TextDecoderStream()).pipeThrough(new TextLineStream({ skipEmptyLines: processLine }));
if (processLine) {
stream = stream.pipeThrough(new ProcessLineStream());
}