mirror of
https://github.com/SukkaW/Surge.git
synced 2025-12-12 01:00:34 +08:00
Remove unused Bun.peek
This commit is contained in:
parent
6e32af4dc8
commit
7167be852f
@ -19,10 +19,7 @@ export const getAppleCdnDomainsPromise = createMemoizedPromise(() => fsFetchCach
|
||||
|
||||
export const buildAppleCdn = task(import.meta.path, async (span) => {
|
||||
const promise = getAppleCdnDomainsPromise();
|
||||
const peeked = Bun.peek(promise);
|
||||
const res: string[] = peeked === promise
|
||||
? await span.traceChildPromise('get apple cdn domains', promise)
|
||||
: (peeked as string[]);
|
||||
const res: string[] = await span.traceChildPromise('get apple cdn domains', promise);
|
||||
|
||||
const description = [
|
||||
...SHARED_DESCRIPTION,
|
||||
|
||||
@ -14,11 +14,7 @@ export const getChnCidrPromise = createMemoizedPromise(async () => {
|
||||
});
|
||||
|
||||
export const buildChnCidr = task(import.meta.path, async (span) => {
|
||||
const cidrPromise = getChnCidrPromise();
|
||||
const peeked = Bun.peek(cidrPromise);
|
||||
const filteredCidr: string[] = peeked === cidrPromise
|
||||
? await span.traceChildPromise('download chnroutes2', cidrPromise)
|
||||
: (peeked as string[]);
|
||||
const filteredCidr = await span.traceChildAsync('download chnroutes2', getChnCidrPromise);
|
||||
|
||||
// Can not use SHARED_DESCRIPTION here as different license
|
||||
const description = [
|
||||
|
||||
@ -21,7 +21,7 @@ const s = new Sema(2);
|
||||
const latestTopUserAgentsPromise = fsFetchCache.apply(
|
||||
'https://cdn.jsdelivr.net/npm/top-user-agents@latest/src/desktop.json',
|
||||
() => fetchWithRetry('https://cdn.jsdelivr.net/npm/top-user-agents@latest/src/desktop.json')
|
||||
.then(res => res.json())
|
||||
.then(res => res.json() as any)
|
||||
.then((userAgents: string[]) => userAgents.filter(ua => ua.startsWith('Mozilla/5.0 '))),
|
||||
{
|
||||
serializer: serializeArray,
|
||||
@ -61,7 +61,7 @@ const querySpeedtestApi = async (keyword: string): Promise<Array<string | null>>
|
||||
retry: {
|
||||
retries: 2
|
||||
}
|
||||
})).then(r => r.json()).then((data: Array<{ url: string }>) => data.reduce<string[]>(
|
||||
})).then(r => r.json() as any).then((data: Array<{ url: string }>) => data.reduce<string[]>(
|
||||
(prev, cur) => {
|
||||
const hn = getHostname(cur.url, { detectIp: false });
|
||||
if (hn) {
|
||||
|
||||
@ -33,11 +33,7 @@ export const getTelegramCIDRPromise = createMemoizedPromise(async () => {
|
||||
});
|
||||
|
||||
export const buildTelegramCIDR = task(import.meta.path, async (span) => {
|
||||
const promise = getTelegramCIDRPromise();
|
||||
const peeked = Bun.peek(promise);
|
||||
const { date, results } = peeked === promise
|
||||
? await span.traceChildPromise('get telegram cidr', promise)
|
||||
: (peeked as { date: Date, results: string[] });
|
||||
const { date, results } = await span.traceChildAsync('get telegram cidr', getTelegramCIDRPromise);
|
||||
|
||||
if (results.length === 0) {
|
||||
throw new Error('Failed to fetch data!');
|
||||
|
||||
@ -65,10 +65,7 @@ export const downloadPreviousBuild = task(import.meta.path, async (span) => {
|
||||
const extract = tarStream.extract();
|
||||
|
||||
pipeline(
|
||||
Readable.fromWeb(
|
||||
// @ts-expect-error -- DOM type is incompatible with Node type
|
||||
resp.body
|
||||
),
|
||||
Readable.fromWeb(resp.body),
|
||||
gunzip,
|
||||
extract
|
||||
);
|
||||
|
||||
@ -44,7 +44,6 @@ const getBunBlob = (file: string | URL | BunFile) => {
|
||||
return file;
|
||||
};
|
||||
|
||||
// @ts-expect-error -- ReadableStream<string> should be AsyncIterable<string>
|
||||
export const readFileByLine: ((file: string | URL | BunFile) => AsyncIterable<string>) = enableTextLineStream
|
||||
? (file: string | URL | BunFile) => getBunBlob(file).stream().pipeThrough(new PolyfillTextDecoderStream()).pipeThrough(new TextLineStream())
|
||||
: (file: string | URL | BunFile) => createTextLineAsyncIterableFromStreamSource(getBunBlob(file).stream());
|
||||
@ -59,7 +58,6 @@ const ensureResponseBody = (resp: Response) => {
|
||||
return resp.body;
|
||||
};
|
||||
|
||||
// @ts-expect-error -- ReadableStream<string> should be AsyncIterable<string>
|
||||
export const createReadlineInterfaceFromResponse: ((resp: Response) => AsyncIterable<string>) = enableTextLineStream
|
||||
? (resp) => ensureResponseBody(resp).pipeThrough(new PolyfillTextDecoderStream()).pipeThrough(new TextLineStream())
|
||||
: (resp) => createTextLineAsyncIterableFromStreamSource(ensureResponseBody(resp));
|
||||
|
||||
@ -7,7 +7,7 @@
|
||||
const SENTINEL = Symbol('SENTINEL');
|
||||
const PARENT = Symbol('Parent Node');
|
||||
|
||||
const noop: VoidFunction = () => { /** noop */ };
|
||||
const noop = () => { /** noop */ };
|
||||
|
||||
type TrieNode = {
|
||||
[SENTINEL]: boolean,
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"target": "esnext",
|
||||
"lib": ["DOM", "DOM.Iterable"],
|
||||
"lib": ["ESNext"],
|
||||
"moduleDetection": "force",
|
||||
"module": "esnext",
|
||||
"moduleResolution": "bundler",
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user