File size: 494 Bytes
4e23b01 | 1 2 3 4 5 6 7 8 9 10 11 | const TRUE_BOOLEAN_ENV_VALUES = new Set(['1', 'true', 'yes', 'on']);
const FALSE_BOOLEAN_ENV_VALUES = new Set(['0', 'false', 'no', 'off']);
export function parseBooleanEnv(value: string | undefined): boolean | undefined {
const normalized = value?.trim().toLowerCase();
if (normalized === undefined || normalized.length === 0) return undefined;
if (TRUE_BOOLEAN_ENV_VALUES.has(normalized)) return true;
if (FALSE_BOOLEAN_ENV_VALUES.has(normalized)) return false;
return undefined;
}
|