index.js
function getCorrection(words, match) {
	for (const word of words) {
		const pattern = getPattern(word);
		if (!getRegExp([pattern]).test(match)) {
			continue;
		}

		const corrected = match.replace(new RegExp(`\\b${pattern}`, 'i'), word);
		return matchCasing(corrected, match);
	}

	return false;
}
function getCorrection(words, match) {
	for (const word of words) {
		const pattern = getPattern(word);
		if (!getRegExp([pattern]).test(match)) {
			continue;
		}

		const corrected = match.replace(new RegExp(`\\b${pattern}`, 'i'), word);
		return matchCasing(corrected, match);
	}

	return false;
}
function getCorrection ( words , match ) { for ( const word of words ) { const pattern = getPattern ( word ) ; if ( ! getRegExp ( [ pattern ] ) . test ( match ) ) { continue ; } const corrected = match . replace ( new RegExp ( ` \\ ${ pattern } ` , 'i' ) , word ) ; return matchCasing ( corrected , match ) ; } return false ; }
Return a correct word based on found incorrect word.
Keeps case and suffix of an original word.

@param {string[]} words
@param {string} match
@return {string|boolean}
Return a correct word based on found incorrect word . Keeps case and suffix of an original word .