import { Str } from '@rimbu/typical'; import { ReplaceAllIf } from '../typescript/String.types'; /** */ export type Case = 'upper' | 'lower'; /** * Transforms a given string type `T` by replacing all occurrences of 'ae' with 'ä', * 'oe' with 'ö', and 'ue' with 'ü'. * * @template T - The string type to be transformed. * @returns A new string type with the specified replacements applied. */ export type ToUmlautReturn = ReplaceAllIf, 'oe', 'ö'>, 'ue', 'ü'>; /** * Transforms a given string type `T` by replacing certain character sequences with their corresponding umlaut characters, * based on the specified case `C`. * * @template T - The string type to be transformed. * @template C - The case type which determines the transformation. Can be either 'lower' or 'upper'. * * @remarks * - If `C` is 'lower', the string `T` is converted to lowercase and umlaut replacements are applied. * - If `C` is 'upper', the string `T` is converted to uppercase and umlaut replacements are applied. * * @returns The transformed string type with umlaut replacements applied. */ export type SetUmlautsReturn = C extends 'lower' ? ToUmlautReturn> : ReplaceAllIf, 'AE', 'Ä'>, 'OE', 'Ö'>, 'UE', 'Ü'>; /** * A utility type that removes umlauts from a given string and replaces them with their respective digraphs. * The replacement is based on the specified case ('lower' or 'upper'). * * @template T - The input string type. * @template C - The case type, either 'lower' or 'upper'. * * @remarks * - If `C` is 'lower', it replaces 'ä' with 'ae', 'ö' with 'oe', and 'ü' with 'ue'. * - If `C` is 'upper', it replaces 'Ä' with 'AE', 'Ö' with 'OE', and 'Ü' with 'UE'. * * @example * ```typescript * type Result1 = RemoveUmlautsReturn<'München', 'lower'>; // 'Muenchen' * type Result2 = RemoveUmlautsReturn<'MÜNCHEN', 'upper'>; // 'MUENCHEN' * ``` */ export type RemoveUmlautsReturn = C extends 'lower' ? ReplaceAllIf, 'ä', 'ae'>, 'ö', 'oe'>, 'ü', 'ue'> : ReplaceAllIf, 'Ä', 'AE'>, 'Ö', 'OE'>, 'Ü', 'UE'>;