The type of the metric result, defaults to MetricRaw
ProtectedconstructorCreates a new CmpStr instance with the given options.
The constructor is protected to enforce the use of the static create method.
The type of the metric result, defaults to MetricRaw
Optionalopt: string | CmpStrOptionsOptional serialized or options object
ProtectedoptionsStatic ReadonlyclearClears the caches for normalizer, filter pipelines, metric, and phonetic modules.
Static ReadonlyfilterAdds, removes, pauses, resumes, lists, or clears global filters.
Static ReadonlymetricAdds, removes, checks, or lists available metrics.
Static ReadonlyphoneticAdds, removes, checks, or lists available phonetic algorithms and mappings.
Static ReadonlyprofilerProvides access to the global profiler services.
ProtectedassertProtectedassertAssert multiple conditions.
Array of [ condition, value ] pairs
Performs a batch metric comparison and returns results sorted by score.
The type of the metric result
The source string or array of strings
The target string or array of strings
Optionaldir: "desc" | "asc" = 'desc'Sort direction (desc, asc)
Optionalopt: CmpStrOptionsOptional options
Performs a batch metric comparison between source and target strings or array of strings.
The type of the metric result
The source string or array of strings
The target string or array of strings
Optionalopt: CmpStrOptionsOptional options
Returns the n closest matches from a batch comparison.
The type of the metric result
The source string or array of strings
The target string or array of strings
Optionaln: number = 1Number of closest matches
Optionalopt: CmpStrOptionsOptional options
Performs a single metric comparison and returns only the numeric score.
The source string
The target string
Optionalopt: CmpStrOptionsOptional options
ProtectedcomputeComputes the metric result for the given inputs, applying normalization and filtering as configured.
The type of the metric result
The first input string or array
The second input string or array
Optionalopt: CmpStrOptionsOptional options to use
Optionalmode: MetricModeThe metric mode to use
Optionalraw: booleanWhether to return raw results
Optionalskip: booleanWhether to skip normalization and filtering
ProtectedfilterApplies all active filters to the input string or array.
The input string or array
Optionalhook: FilterHooksThe filter hook
Returns the n furthest matches from a batch comparison.
The type of the metric result
The source string or array of strings
The target string or array of strings
Optionaln: number = 1Number of furthest matches
Optionalopt: CmpStrOptionsOptional options
Returns a specific option value by path.
The path to the option
Returns the options as a JSON string.
ProtectedindexComputes the phonetic index for the given input using the specified phonetic algorithm.
The input string or array
The phonetic algorithm and options
Performs a batch comparison and returns only results above the threshold.
The type of the metric result
The source string or array of strings
The target string or array of strings
The similarity threshold (0..1)
Optionalopt: CmpStrOptionsOptional options
Computes a similarity matrix for the given input array.
The input array
Optionalopt: CmpStrOptionsOptional options
ProtectednormalizeNormalizes the input string or array using the configured or provided flags.
The input string or array
Optionalflags: stringNormalization flags
ProtectedoutputResolves the result format (raw or formatted).
The type of the metric result
The metric result
Optionalraw: booleanWhether to return raw results
Performs a pairwise metric comparison between source and target strings or array of strings.
Input arrays needs of the same length to perform pairwise comparison, otherwise the method will throw an error.
The type of the metric result
The source string or array of strings
The target string or array of strings
Optionalopt: CmpStrOptionsOptional options
Computes the phonetic index for a string using the configured or given algorithm.
Optionalinput: stringThe input string
Optionalalgo: stringThe phonetic algorithm to use
Optionalopt: PhoneticOptionsOptional phonetic options
ProtectedpostPost-process the results of the metric computation.
The metric result
Optionalopt: CmpStrOptionsProtectedpreparePrepares the input by normalizing and filtering.
Optionalinput: MetricInputThe input string or array
Optionalopt: CmpStrOptionsOptional options to use
Resets the instance, clearing all data and options.
ProtectedresolveResolves the options for the CmpStr instance, merging the provided options with the existing options.
Optionalopt: CmpStrOptionsOptional options to merge
Removes the normalization flags entirely.
Removes an option at the given path.
The path to the option
Removes the processors entirely.
Performs a normalized and filtered substring search.
The search string
The array to search in
Optionalflags: stringNormalization flags
Optionalprocessors: CmpStrProcessorsPre-processors to apply
Sets the normalization flags (e.g., 'itw', 'nfc').
The normalization flags
Sets the similatity metric to use (e.g., 'levenshtein', 'dice').
The metric name
Sets a specific option at the given path.
The path to the option
The value to set
Sets the pre-processors to use for preparing the input.
The processors to set
Enable or disable raw output.
Whether to enable or disable raw output
Sets the serialized options from a JSON string.
The serialized options
ProtectedstructuredCreates a instance for processing structured data.
The type of objects in the data array
Returns the n closest matches from a batch comparison of structured data.
The type of objects in the data array
The query string to compare against
The array of structured objects
The property key to extract for comparison
Optionaln: number = 1Number of closest matches
Optionalopt: StructuredDataOptionsOptional lookup options
Returns the n furthest matches from a batch comparison of structured data.
The type of objects in the data array
The query string to compare against
The array of structured objects
The property key to extract for comparison
Optionaln: number = 1Number of furthest matches
Optionalopt: StructuredDataOptionsOptional lookup options
Performs a batch comparison against structured data by extracting a specific property and returning results with original objects attached.
The type of objects in the data array
The query string to compare against
The array of structured objects
The property key to extract for comparison
Optionalopt: StructuredDataOptionsOptional lookup options
Performs a batch comparison and returns only results above the threshold for structured data.
The type of objects in the data array
The query string to compare against
The array of structured objects
The property key to extract for comparison
The similarity threshold (0..1)
Optionalopt: StructuredDataOptionsOptional lookup options
Performs a pairwise comparison between two arrays of structured objects by extracting specific properties and returning results with original objects attached.
The type of objects in the arrays
The type of objects in the other array
The array of structured objects
The property key to extract for comparison
The other array of structured objects
The property key to extract from other array
Optionalopt: StructuredDataOptionsOptional lookup options
Performs a single metric comparison between the source and target.
The type of the metric result
The source string
The target string
Optionalopt: CmpStrOptionsOptional options
StaticanalyzeReturns a TextAnalyzer instance for the given input string.
Optionalinput: stringThe input string
StaticcreateCreates a new CmpStr instance with the given options.
Optionalopt: string | CmpStrOptionsOptional serialized or options object
StaticdiffReturns a DiffChecker instance for computing the unified diff between two texts.
The first (original) text
The second (modified) text
Optionalopt: DiffOptionsOptional diff configuration
The main CmpStr class that provides a unified interface for string comparison, phonetic indexing, filtering, and text analysis.