CmpStr - v3.2.1
    Preparing search index...

    The Normalizer class providing methods to normalize strings based on various flags.

    Index

    Constructors

    Properties

    cache: HashTable<string, string> = ...

    A cache to store normalized strings based on the flags and input. This helps avoid recomputing normalization for the same input and flags.

    pipeline: Map<string, NormalizerFn> = ...

    A map that holds normalization functions based on the flags. This allows for reusing normalization logic without recomputing it.

    REGEX: {
        doubleChars: RegExp;
        nonLetters: RegExp;
        nonNumbers: RegExp;
        specialChars: RegExp;
        whitespace: RegExp;
    } = ...

    Regular expressions used in normalization steps

    Methods

    • Returns a canonical version of the flags by removing duplicates and sorting them.

      Parameters

      • flags: string

        The normalization flags

      Returns string

      • The canonicalized flags
    • Clears the normalization pipeline and cache. This is useful for resetting the state of the Normalizer.

      Returns void

    • Returns a normalization function based on the provided flags. The flags are a string of characters that define the normalization steps.

      Parameters

      • flags: string

        A string of characters representing the normalization steps

      Returns NormalizerFn

      • A function that normalizes a string based on the provided flags
    • Normalizes the input string or array of strings based on the provided flags. The flags are a string of characters that define the normalization steps.

      Parameters

      • input: string | string[]

        The string or array of strings to normalize

      • flags: string

        A string of characters representing the normalization steps

      Returns string | string[]

      • The normalized string(s)
    • Asynchronously normalizes the input string or array of strings based on the provided flags. This method is useful for handling large inputs or when normalization needs to be done in a non-blocking way.

      Parameters

      • input: string | string[]

        The string or array of strings to normalize

      • flags: string

        A string of characters representing the normalization steps

      Returns Promise<string | string[]>

      • A promise that resolves to the normalized string(s)