import { type MapFunction } from '../value/map'; import { type Maybe } from '../value/maybe.type'; /** * Trims leading and trailing whitespace from a string. * * @param input The string to trim. * @returns The trimmed string. */ export declare function stringTrimFunction(input: string): string; /** * Converts a string to uppercase. * * @param input The string to convert. * @returns The uppercase string. */ export declare function stringToUppercaseFunction(input: string): string; /** * Converts a string to lowercase. * * @param input The string to convert. * @returns The lowercase string. */ export declare function stringToLowercaseFunction(input: string): string; /** * Configuration for transforming a string. * Defines operations like trimming, case conversion, or applying a custom transform function. * * @template S The specific string type, defaults to `string`. */ export type TransformStringFunctionConfig = { /** * If true, the string will be trimmed of leading/trailing whitespace. * Trimming occurs before other transformations like case conversion or a custom `transform` function. */ readonly trim?: boolean; /** * If true, the string will be converted to lowercase. * This is ignored if a custom `transform` function is provided. */ readonly toLowercase?: boolean; /** * If true, the string will be converted to uppercase. * This is ignored if a custom `transform` function is provided and takes precedence over `toLowercase` if both are true. */ readonly toUppercase?: boolean; /** * Slices the string based on the configuration. */ readonly slice?: SliceStringFunctionConfig; /** * An optional custom function to transform the string. * If provided, `toLowercase` and `toUppercase` are ignored. Trimming (if `trim` is true) occurs before this custom transform. */ readonly transform?: TransformStringFunction; }; /** * A reference object holding a `TransformStringFunctionConfig`. * * @template S The specific string type, defaults to `string`. */ export interface TransformStringFunctionConfigRef { /** * The string transformation configuration. */ readonly transform: TransformStringFunctionConfig; } /** * A function that maps a string of type S to another string of type S. * * @template S The specific string type, defaults to `string`. */ export type TransformStringFunction = MapFunction; /** * Input type for string transformation configuration. * Can be a full `TransformStringFunctionConfig` object or a direct `TransformStringFunction`. * * @template S The specific string type, defaults to `string`. */ export type TransformStringFunctionConfigInput = TransformStringFunctionConfig | TransformStringFunction; /** * Normalizes a `TransformStringFunctionConfigInput` into a `TransformStringFunctionConfig` object. * If the input is a function, it's wrapped into a config object with that function as the `transform` property. * If the input is undefined, it returns undefined. * * @template S The specific string type, defaults to `string`. * @param config The configuration input to normalize. * @returns A `TransformStringFunctionConfig` object, or `undefined` if the input config is undefined. */ export declare function transformStringFunctionConfig(config?: TransformStringFunctionConfigInput): Maybe>; /** * Creates a string transformation function based on the provided configuration. * The resulting function will apply transformations in a specific order: * 1. Trimming (if `config.trim` is true). * 2. Slicing (if `config.slice` is provided). * 2. Custom `config.transform` function (if provided). * 3. Uppercase conversion (if `config.toUppercase` is true and no `config.transform`). * 4. Lowercase conversion (if `config.toLowercase` is true and no `config.transform` or `config.toUppercase`). * If no transformations are specified, the identity function is returned. * * @template S The specific string type, defaults to `string`. * @param config The `TransformStringFunctionConfig` detailing the transformations. * @returns A `TransformStringFunction` that applies the configured transformations. */ export declare function transformStringFunction(config: TransformStringFunctionConfig): TransformStringFunction; /** * Adds a prefix to the input string if it does not already start with that prefix. * * @param prefix - The prefix to add. * @param input - The string to modify. * @returns The string with the prefix applied. */ export declare function addPrefix(prefix: string, input: string): string; /** * Function that adds a configured prefix to the input string if it does not exist on that string. */ export type AddPrefixFunction = (input: string) => string; /** * Creates a function that adds a configured prefix to the input string if it does not exist on that string. * * @param prefix The prefix to add. * @returns A function that adds the prefix to a string. */ export declare function addPrefixFunction(prefix: string): AddPrefixFunction; /** * Function that adds a configured suffix to the input string if it does not exist on that string. */ export type AddSuffixFunction = TransformStringFunction; /** * Adds a suffix to a string if it does not already end with that suffix. * * @param suffix The suffix to add. * @param input The string to modify. * @returns The modified string. */ export declare function addSuffix(suffix: string, input: string): string; /** * Creates a function that adds a configured suffix to the input string if it does not exist on that string. * * @param suffix The suffix to add. * @returns A function that adds the suffix to a string. */ export declare function addSuffixFunction(suffix: string): AddSuffixFunction; /** * Function that pads the start of a string to a minimum length. */ export type PadStartFunction = TransformStringFunction; /** * Pads the start of a string to a minimum length. * * @param minLength The minimum length of the string. * @param padCharacter The character to use for padding. * @returns A function that pads the start of a string. */ export declare function padStartFunction(minLength: number, padCharacter: string): PadStartFunction; /** * Function that slices and concats parts of a string based on the configuration. */ export type SliceStringFunction = TransformStringFunction; /** * Configuration for sliceStringFunction() */ export interface SliceStringFunctionConfig { /** * The number of characters to take from the start of the string. * * When both fromStart and fromEnd are specified, the first N characters are concatenated with the last M characters. * If the total (fromStart + fromEnd) is greater than or equal to the string length, the entire string is returned. * * If undefined or 0, only takes from the end of the string. The absolute value of this number is used. */ readonly fromStart?: number; /** * The number of characters to take from the end of the string. * * When both fromStart and fromEnd are specified, the first N characters are concatenated with the last M characters. * If the total (fromStart + fromEnd) is greater than or equal to the string length, the entire string is returned. * * If undefined or 0, only takes from the start of the string. The absolute value of this number is used. */ readonly fromEnd?: number; } /** * Creates a function that slices and concats parts of a string based on the configuration. * * @param config The configuration for the slice function. * @returns A SliceStringFunction. */ export declare function sliceStringFunction(config: SliceStringFunctionConfig): SliceStringFunction;