mirror of
https://github.com/SukkaW/Surge.git
synced 2026-01-28 17:41:54 +08:00
Replace more utilities w/ foxts
This commit is contained in:
@@ -1,9 +0,0 @@
|
||||
import type { Writable } from 'node:stream';
|
||||
import { once } from 'node:events';
|
||||
|
||||
export function asyncWriteToStream<T>(stream: Writable, chunk: T) {
|
||||
const res = stream.write(chunk);
|
||||
if (!res) {
|
||||
return once(stream, 'drain'); // returns a promise only if needed
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
@@ -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<TPreprocessed = unknown> {
|
||||
protected domainTrie = new HostnameSmolTrie(null);
|
||||
|
||||
Reference in New Issue
Block a user