import { type Maybe } from '../value/maybe.type'; /** * A character or string that is added to the start of a string. * * Example: '-' in "-class" * * @semanticType * @semanticTopic string * @semanticTopic dereekb-util:prefix */ export type CharacterPrefix = string; /** * A character or string that is added to the end of a string. * * Example: '-' in "class-" * * @semanticType * @semanticTopic string * @semanticTopic dereekb-util:prefix */ export type CharacterSuffix = string; /** * Does not have a CharacterPrefix or CharacterSuffix. * * @semanticType * @semanticTopic string * @semanticTopic dereekb-util:prefix */ export type CharacterPrefixSuffixCleanString = string; /** * Is a combination of a prefix and suffix. */ export type CharacterPrefixSuffixString

= `${P}${T}${S}`; /** * Has a known prefix. */ export type CharacterPrefixString

= CharacterPrefixSuffixString; /** * Has a known suffix. */ export type CharacterSuffixString = CharacterPrefixSuffixString<'', S, T>; /** * Configuration for creating a {@link CharacterPrefixSuffixInstance} that manages adding and removing prefix/suffix strings. * * @template P - The prefix string type. * @template S - The suffix string type. */ export interface CharacterPrefixSuffixInstanceConfiguration

{ /** * The prefix characters to add/remove to/from the start of the string. */ readonly prefix?: Maybe

; /** * The suffix characters to add/remove to/from the end of the string. */ readonly suffix?: Maybe; /** * If true, the prefix will be added to empty strings. */ readonly prefixEmptyString?: boolean; /** * If true, the suffix will be added to empty strings. */ readonly suffixEmptyString?: boolean; } /** * Instance that can add or remove a configured prefix and/or suffix from strings. * * @template P - The prefix string type. * @template S - The suffix string type. */ export interface CharacterPrefixSuffixInstance

extends CharacterPrefixSuffixInstanceConfiguration { /** * Adds the prefix and suffix to the input string. Cleans any existing prefix/suffix before adding. * * @param input - The string to prefix and suffix. * @returns The string with prefix and suffix applied. */ prefixSuffixString(input: ''): string; prefixSuffixString(input: T | CharacterPrefixSuffixString | CharacterPrefixString | CharacterSuffixString): CharacterPrefixSuffixString; prefixSuffixString(input: string): CharacterPrefixSuffixString; /** * Removes the prefix and suffix from the input string, stripping repeated occurrences. * * @param input - The string to clean. * @returns The string with prefix and suffix removed. */ cleanString(input: T | CharacterPrefixSuffixString | CharacterPrefixString | CharacterSuffixString): T; cleanString(input: string): string; } /** * Creates a {@link CharacterPrefixSuffixInstance} that can add or remove configured prefix/suffix strings. * * @param config - Configuration specifying the prefix, suffix, and empty string behavior. * @returns A new instance for managing prefix/suffix operations on strings. */ export declare function characterPrefixSuffixInstance

(config: CharacterPrefixSuffixInstanceConfiguration): CharacterPrefixSuffixInstance; /** * Removes the given suffix from the input string when present, or * returns `undefined` when the input does not end with the suffix. * * Use this when callers want to detect whether the suffix was present * (vs. {@link removeFirstMatchingSuffix}, which silently passes the * input through). * * @param input - The string to trim. * @param suffix - The suffix to remove. * @returns The input without the suffix, or `undefined` when the input * does not end with the suffix. */ export declare function removeSuffix(input: string, suffix: string): Maybe; /** * Removes the first matching suffix from the input string. Returns the * input unchanged when none of the suffixes match. * * @param input - The string to trim. * @param suffixes - The suffixes to try in order. * @returns The input with the first matching suffix removed, or the * input unchanged when no suffix matches. */ export declare function removeFirstMatchingSuffix(input: string, suffixes: readonly string[]): string; /** * A string with a dash prefix. * * Example: "-class" */ export type DashPrefixString = CharacterPrefixString<'-'>; /** * A pre-configured instance that can be used to add/remove dash prefixes from a string. */ export declare const DASH_CHARACTER_PREFIX_INSTANCE: CharacterPrefixSuffixInstance<"-", "">;