docs
evals
scenario-1
scenario-10
scenario-2
scenario-3
scenario-4
scenario-5
scenario-6
scenario-7
scenario-8
scenario-9
A utility that combines base defaults, environment overrides, and user overrides into a shaped configuration object while keeping only the requested top-level keys.
{ service: { host: "localhost", port: 3000 }, security: { cors: false } }, environment overrides { service: { port: 8080, host: undefined } }, and user overrides { security: { cors: true } }, the result is { service: { host: "localhost", port: 8080 }, security: { cors: true } } and the base defaults remain unmodified. @test{ service: { port: 3000, ssl: false }, debug: false }, overrides { service: { ssl: true }, debug: true, extras: { verbose: true } }, and allowKeys: ["service"], the final result is { service: { port: 3000, ssl: true } } (all other top-level keys are dropped while keeping deep defaults). @test{ retries: 2, timeout: 1000 }, user overrides { retryCount: 5 }, and renameMap: { "retryCount": "retries" }, the result is { retries: 5, timeout: 1000 } while ignoring unknown keys. @testincomingKey -> canonicalKey).undefined in overrides do not overwrite existing data; other falsey values (like null or 0) do.export interface NormalizeOptions {
allowKeys?: string[];
renameMap?: Record<string, string>;
}
export function normalizeConfig(
baseDefaults: Record<string, any>,
envConfig?: Record<string, any> | undefined,
userConfig?: Record<string, any> | undefined,
options?: NormalizeOptions | undefined
): Record<string, any>;Utility helpers for deep merging, defaulting, and object reshaping.