Use foxts more
Some checks failed
Build / Build (push) Has been cancelled
Build / Diff output (push) Has been cancelled
Build / Deploy to Cloudflare Pages (3.114.12) (push) Has been cancelled
Build / Deploy to GitHub and GitLab (push) Has been cancelled

This commit is contained in:
SukkaW
2025-10-10 05:01:58 +08:00
parent eb5a2c73bb
commit 8ccc5d6b5b
3 changed files with 3 additions and 22 deletions

View File

@@ -7,7 +7,8 @@ import { treeDir, TreeFileType } from './lib/tree-dir';
import type { TreeType, TreeTypeArray } from './lib/tree-dir';
import { OUTPUT_MOCK_DIR, OUTPUT_MODULES_RULES_DIR, PUBLIC_DIR, ROOT_DIR } from './constants/dir';
import { fastStringCompare, writeFile } from './lib/misc';
import { writeFile } from './lib/misc';
import { fastStringCompare } from 'foxts/fast-string-compare';
import type { VoidOrVoidArray } from './lib/misc';
import picocolors from 'picocolors';
import { tagged as html } from 'foxts/tagged';

View File

@@ -6,26 +6,6 @@ import { appendArrayInPlace } from 'foxts/append-array-in-place';
export type MaybePromise<T> = T | Promise<T>;
export function fastStringCompare(a: string, b: string) {
const lenA = a.length;
const lenB = b.length;
const minLen = lenA < lenB ? lenA : lenB;
for (let i = 0; i < minLen; ++i) {
const ca = a.charCodeAt(i);
const cb = b.charCodeAt(i);
if (ca > cb) return 1;
if (ca < cb) return -1;
}
if (lenA === lenB) {
return 0;
}
return lenA > lenB ? 1 : -1;
};
interface Write {
(
destination: string,

View File

@@ -2,7 +2,7 @@
* Hostbane-Optimized Trie based on Mnemonist Trie
*/
import { fastStringCompare } from './misc';
import { fastStringCompare } from 'foxts/fast-string-compare';
import util from 'node:util';
import { noop } from 'foxts/noop';
import { fastStringArrayJoin } from 'foxts/fast-string-array-join';