@dcoffey/espells
Version:
Pure JS/TS spellchecker, using Hunspell dictionaries. Based on Spylls.
30 lines (29 loc) • 1.13 kB
TypeScript
/**
* A replacement pattern describes a pattern and its replacement, with the
* pattern matching a common typo in a word, and the replacement being the
* relevant correction for that typo. It uses the following syntax:
*
* ```text
* REP <number of entries>
* REP <pattern> <replacement>
* ```
*
* The `pattern` syntax supports `^` and `$` anchors, like `RegExp`. In the
* `replacement` string, a `_` underscore can be used in the string to
* represent a space, e.g. correcting `alot` to `a lot`, using the
* `replacement` `a_lot`.
*/
export declare class RepPattern {
/** The `RegExp` pattern to replace. */
pattern: RegExp;
/** The string to replace anything matched by `pattern` with. */
replacement: string;
/**
* @param pattern - The pattern to replace. Is treated as a `RegExp`, but
* given as a string.
* @param replacement - The string to replace anything matched by `pattern` with.
*/
constructor(pattern: string, replacement: string);
/** Yields the permutations of a word with this `RepPattern` applied to it. */
replace(word: string): Iterable<string>;
}