BuildTrieOptions
Options that apply to the trie globally.When true, treats all apostrophe-like characters as equivalent during matching. This allows a rule with “don’t” to match “don’t”, “don’t”, “don`t”, etc.
ConfirmCallback
A callback function used to determine if a rule should be considered based on confirmation options.The options specifying the conditions for confirmation.
A boolean indicating whether the rule is considered (true) or not (false).
OptimizeResult
Result of rule optimization including optimized rules and statistics.The optimized array of rules with redundancies removed and options consolidated.
Statistics about the optimization process.
Warnings about potential issues found during optimization.
Rule
Represents a single search and replace rule. Defines the source words to search for and the target replacement.An array of strings representing the words or patterns to search for. Each string in the array is treated as an individual search target.
The target string to replace the matched source words with. Can include additional formatting or contextual information.
Options that modify the behavior of the rule, such as casing and clipping.
RuleOptions
Options that define how a rule behaves during search and replace operations.Specifies how casing should be handled during replacement. Defaults to case-sensitive if not provided.
A regular expression or predefined pattern to determine characters to clip at the end of a match. Useful for removing trailing punctuation or symbols.
A regular expression or predefined pattern to determine characters to clip at the start of a match. Useful for removing leading punctuation or symbols.
Options that determine whether the rule should be confirmed before being applied.
Specifies the type of match required for the rule to be applied. Determines the context in which the rule should match words.
A prefix string to be added before the replacement text. Useful for maintaining consistent formatting or adding necessary context.
SearchAndReplaceOptions
Options for configuring search and replace operations.A callback function that determines whether a rule should be considered based on confirmation options. Allows for dynamic decision-making during the replacement process.
A logging function that receives information about the current node being processed. Useful for debugging or tracking the replacement process.
TrieNode
Represents a node within a trie data structure used for efficient search and replace operations.An index signature allowing dynamic properties. Each key represents a character, and the value can be:
- A boolean indicating if it’s the end of a word.
- RuleOptions modifying the rule’s behavior.
- A string representing the target replacement.
- Another TrieNode for nested characters.
- Undefined if the character path does not exist.
Build options stored at the trie root to be used during search operations. Only present on the root node.
Indicates whether the current node marks the end of a complete word. Useful for determining when a match is found.
Options associated with the rule at this node. Can modify behavior such as casing, clipping, and matching types.
The target replacement string for the rule at this node. Defines what the matched word should be replaced with.