@@ -49,23 +49,8 @@ export function normalizeLowercaseStringOrEmpty(value: unknown): string {
4949 return normalizeOptionalLowercaseString ( value ) ?? "" ;
5050}
5151
52- /** Return the raw string value or `undefined`. No trimming. */
53- export function readStringValue ( value : unknown ) : string | undefined {
54- return typeof value === "string" ? value : undefined ;
55- }
56-
57- /** Return true when the value is a non-empty trimmed string. */
58- export function hasNonEmptyString ( value : unknown ) : value is string {
59- return normalizeOptionalString ( value ) !== undefined ;
60- }
61-
6252// ---- Record coercion ----
6353
64- /** Coerce a value into a `Record<string, unknown>`, defaulting to `{}`. */
65- export function asRecord ( value : unknown ) : Record < string , unknown > {
66- return typeof value === "object" && value !== null ? ( value as Record < string , unknown > ) : { } ;
67- }
68-
6954/** Coerce a value into a `Record<string, unknown>` or `undefined`. */
7055export function asOptionalObjectRecord ( value : unknown ) : Record < string , unknown > | undefined {
7156 return value && typeof value === "object" ? ( value as Record < string , unknown > ) : undefined ;
@@ -80,37 +65,6 @@ export function readStringField(
8065 return typeof v === "string" ? v : undefined ;
8166}
8267
83- /** Read a number field from a record. */
84- export function readNumberField (
85- record : Record < string , unknown > | null | undefined ,
86- key : string ,
87- ) : number | undefined {
88- const v = record ?. [ key ] ;
89- return typeof v === "number" ? v : undefined ;
90- }
91-
92- /** Read a boolean field from a record. */
93- export function readBooleanField (
94- record : Record < string , unknown > | null | undefined ,
95- key : string ,
96- ) : boolean | undefined {
97- const v = record ?. [ key ] ;
98- return typeof v === "boolean" ? v : undefined ;
99- }
100-
101- /** Coerce a value into a string→string map, filtering out non-string values. */
102- export function readStringMap ( value : unknown ) : Record < string , string > {
103- const record = asOptionalObjectRecord ( value ) ;
104- if ( ! record ) {
105- return { } ;
106- }
107- return Object . fromEntries (
108- Object . entries ( record ) . flatMap ( ( [ key , entryValue ] ) =>
109- typeof entryValue === "string" ? [ [ key , entryValue ] ] : [ ] ,
110- ) ,
111- ) ;
112- }
113-
11468// ---- Filename normalization ----
11569
11670/**
0 commit comments