mirror of
https://github.com/SukkaW/Surge.git
synced 2026-01-28 17:41:54 +08:00
Refactor: drop Bun.inspect and Bun.version
This commit is contained in:
10
.swcrc
Normal file
10
.swcrc
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
{
|
||||||
|
"$schema": "https://swc.rs/schema.json",
|
||||||
|
"jsc": {
|
||||||
|
"target": "esnext",
|
||||||
|
"parser": {
|
||||||
|
"syntax": "typescript",
|
||||||
|
"dynamicImport": true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
console.log('Bun version:', Bun.version, Bun.revision);
|
console.log('Version:', process.version, typeof Bun !== 'undefined' ? Bun.revision : '');
|
||||||
|
|
||||||
import { downloadPreviousBuild } from './download-previous-build';
|
import { downloadPreviousBuild } from './download-previous-build';
|
||||||
import { buildCommon } from './build-common';
|
import { buildCommon } from './build-common';
|
||||||
|
|||||||
@@ -69,13 +69,12 @@ export function fetchRemoteTextByLine(url: string | URL) {
|
|||||||
return fetchWithRetry(url, defaultRequestInit).then(createReadlineInterfaceFromResponse);
|
return fetchWithRetry(url, defaultRequestInit).then(createReadlineInterfaceFromResponse);
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function readFileIntoProcessedArray(file: string | URL | BunFile) {
|
export async function readFileIntoProcessedArray(file: string | BunFile | FileHandle) {
|
||||||
if (typeof file === 'string') {
|
const results = [];
|
||||||
file = Bun.file(file);
|
for await (const line of readFileByLine(file)) {
|
||||||
} else if (!('writer' in file)) {
|
if (processLine(line)) {
|
||||||
file = Bun.file(file);
|
results.push(line);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
const content = await file.text();
|
return results;
|
||||||
return content.split('\n').filter(processLine);
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ export class PolyfillTextDecoderStream extends TransformStream<Uint8Array, strin
|
|||||||
readonly ignoreBOM: boolean;
|
readonly ignoreBOM: boolean;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
public readonly encoding: Bun.Encoding = 'utf-8',
|
public readonly encoding: BufferEncoding = 'utf-8',
|
||||||
{
|
{
|
||||||
fatal = false,
|
fatal = false,
|
||||||
ignoreBOM = false
|
ignoreBOM = false
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import { fastStringArrayJoin } from './misc';
|
import { fastStringArrayJoin } from './misc';
|
||||||
|
import { inspect } from 'util';
|
||||||
|
|
||||||
// const { Error, Bun, JSON, Symbol } = globalThis;
|
// const { Error, Bun, JSON, Symbol } = globalThis;
|
||||||
|
|
||||||
@@ -403,7 +404,7 @@ export const createTrie = (from?: string[] | Set<string> | null, hostnameMode =
|
|||||||
},
|
},
|
||||||
whitelist,
|
whitelist,
|
||||||
|
|
||||||
[Bun.inspect.custom]: (depth: number) => JSON.stringify(deepTrieNodeToJSON(root), null, 2).split('\n').map((line) => ' '.repeat(depth) + line).join('\n'),
|
[inspect.custom]: (depth: number) => JSON.stringify(deepTrieNodeToJSON(root), null, 2).split('\n').map((line) => ' '.repeat(depth) + line).join('\n'),
|
||||||
|
|
||||||
hostnameMode,
|
hostnameMode,
|
||||||
smolTree
|
smolTree
|
||||||
|
|||||||
Reference in New Issue
Block a user