diff --git a/Build/build-internal-reverse-chn-cidr.ts b/Build/build-internal-reverse-chn-cidr.ts index ed1f6802..a18802a2 100644 --- a/Build/build-internal-reverse-chn-cidr.ts +++ b/Build/build-internal-reverse-chn-cidr.ts @@ -7,7 +7,7 @@ import { NON_CN_CIDR_INCLUDED_IN_CHNROUTE, RESERVED_IPV4_CIDR } from './constant import fs from 'node:fs'; import { OUTPUT_INTERNAL_DIR } from './constants/dir'; -import { asyncWriteToStream } from './lib/async-write-to-stream'; +import { asyncWriteToStream } from 'foxts/async-write-to-stream'; import { mkdirp } from './lib/misc'; import { appendArrayInPlace } from './lib/append-array-in-place'; diff --git a/Build/lib/async-write-to-stream.ts b/Build/lib/async-write-to-stream.ts deleted file mode 100644 index 64bee6f4..00000000 --- a/Build/lib/async-write-to-stream.ts +++ /dev/null @@ -1,9 +0,0 @@ -import type { Writable } from 'node:stream'; -import { once } from 'node:events'; - -export function asyncWriteToStream(stream: Writable, chunk: T) { - const res = stream.write(chunk); - if (!res) { - return once(stream, 'drain'); // returns a promise only if needed - } -} diff --git a/Build/lib/bitwise.ts b/Build/lib/bitwise.ts deleted file mode 100644 index 363fed1f..00000000 --- a/Build/lib/bitwise.ts +++ /dev/null @@ -1,12 +0,0 @@ -/** Packs two 16-bit integers into one 32-bit integer */ -export const pack = (a: number, b: number): number => (a << 16) | b; - -/** Unpacks two 16-bit integers from one 32-bit integer */ -export function unpack(value: number, arr: [a: number, b: number] = Array.from(new Array(2).keys()) as any): [a: number, b: number] { - arr[0] = (value >> 16) & 0xFFFF; - arr[1] = value & 0xFFFF; - return arr; -} - -export const unpackFirst = (value: number): number => (value >> 16) & 0xFFFF; -export const unpackSecond = (value: number): number => value & 0xFFFF; diff --git a/Build/lib/rules/base.ts b/Build/lib/rules/base.ts index 57a94430..24fbcd71 100644 --- a/Build/lib/rules/base.ts +++ b/Build/lib/rules/base.ts @@ -10,7 +10,7 @@ import fs from 'node:fs'; import { writeFile } from '../misc'; import { fastStringArrayJoin } from 'foxts/fast-string-array-join'; import { readFileByLine } from '../fetch-text-by-line'; -import { asyncWriteToStream } from '../async-write-to-stream'; +import { asyncWriteToStream } from 'foxts/async-write-to-stream'; export abstract class RuleOutput { protected domainTrie = new HostnameSmolTrie(null);