import { type Maybe } from '../value/maybe.type'; /** * A character or string that is added to the start of a string. * * Example: '-' in "-class" */ export type CharacterPrefix = string; /** * A character or string that is added to the end of a string. * * Example: '-' in "class-" */ export type CharacterSuffix = string; /** * A string that does not have a CharacterPrefix or CharacterSuffix. */ export type CharacterPrefixSuffixCleanString = string; /** * A string that is a combination of a prefix and suffix. */ export type CharacterPrefixSuffixString
= `${P}${T}${S}`; /** * A string that has a known prefix. */ export type CharacterPrefixString
= CharacterPrefixSuffixString
;
/**
* A string that 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 | CharacterPrefixString | CharacterSuffixString ;
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 | CharacterPrefixString | CharacterSuffixString (config: CharacterPrefixSuffixInstanceConfiguration ): CharacterPrefixSuffixInstance ;
/**
* 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<"-", "">;
): CharacterPrefixSuffixString): 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