refactor: drop unused qqbot utility exports

This commit is contained in:
Peter Steinberger
2026-05-01 10:01:33 +01:00
parent 4cbd1b53cf
commit c2cb648dc3
2 changed files with 0 additions and 49 deletions

View File

@@ -49,23 +49,8 @@ export function normalizeLowercaseStringOrEmpty(value: unknown): string {
return normalizeOptionalLowercaseString(value) ?? "";
}
/** Return the raw string value or `undefined`. No trimming. */
export function readStringValue(value: unknown): string | undefined {
return typeof value === "string" ? value : undefined;
}
/** Return true when the value is a non-empty trimmed string. */
export function hasNonEmptyString(value: unknown): value is string {
return normalizeOptionalString(value) !== undefined;
}
// ---- Record coercion ----
/** Coerce a value into a `Record<string, unknown>`, defaulting to `{}`. */
export function asRecord(value: unknown): Record<string, unknown> {
return typeof value === "object" && value !== null ? (value as Record<string, unknown>) : {};
}
/** Coerce a value into a `Record<string, unknown>` or `undefined`. */
export function asOptionalObjectRecord(value: unknown): Record<string, unknown> | undefined {
return value && typeof value === "object" ? (value as Record<string, unknown>) : undefined;
@@ -80,37 +65,6 @@ export function readStringField(
return typeof v === "string" ? v : undefined;
}
/** Read a number field from a record. */
export function readNumberField(
record: Record<string, unknown> | null | undefined,
key: string,
): number | undefined {
const v = record?.[key];
return typeof v === "number" ? v : undefined;
}
/** Read a boolean field from a record. */
export function readBooleanField(
record: Record<string, unknown> | null | undefined,
key: string,
): boolean | undefined {
const v = record?.[key];
return typeof v === "boolean" ? v : undefined;
}
/** Coerce a value into a string→string map, filtering out non-string values. */
export function readStringMap(value: unknown): Record<string, string> {
const record = asOptionalObjectRecord(value);
if (!record) {
return {};
}
return Object.fromEntries(
Object.entries(record).flatMap(([key, entryValue]) =>
typeof entryValue === "string" ? [[key, entryValue]] : [],
),
);
}
// ---- Filename normalization ----
/**

View File

@@ -12,9 +12,6 @@
/** Maximum text length for a single QQ Bot message. */
export const TEXT_CHUNK_LIMIT = 5000;
/** Text chunker function signature. */
export type ChunkTextFn = (text: string, limit: number) => string[];
/**
* Naive text chunking fallback.
*