File tree Expand file tree Collapse file tree 1 file changed +19
-0
lines changed Expand file tree Collapse file tree 1 file changed +19
-0
lines changed Original file line number Diff line number Diff line change @@ -166,6 +166,25 @@ export function getNodesWithDelete(root, word) {
166
166
return all . sort ( ( a , b ) => b . length - a . length ) ;
167
167
}
168
168
169
+ /**
170
+ * Adds a wildcard between each character in the word so that single character errors can be found
171
+ * @param { LetterNode } root
172
+ * @param { string } word
173
+ */
174
+ export function getNodesWithAdd ( root , word ) {
175
+ const all = [ ] ;
176
+ for ( let index = 0 ; index < word . length ; ++ index ) {
177
+ const replacement = word . substring ( 0 , index ) + wildcard + word . substring ( index ) ;
178
+ const results = getNodesWithWildcards ( root , replacement ) ;
179
+ for ( const result of results ) {
180
+ if ( result . length > index ) { // Ignore results unaffected by the replacement
181
+ all . push ( result ) ;
182
+ }
183
+ }
184
+ }
185
+ return all . sort ( ( a , b ) => b . length - a . length ) ;
186
+ }
187
+
169
188
/**
170
189
* Swaps pairs of letters so that single pair swaps can be found
171
190
* (Doesn't require wildcards)
You can’t perform that action at this time.
0 commit comments