-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
43 lines (43 loc) · 1.79 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import { canadaPostSaultSteMarieSpelling, lowerCaseSaultSteMarieSpellings, preferredSaultSteMarieSpelling } from './spellings.js';
function sanitizeSpelling(possibleSpelling) {
return possibleSpelling
.trim()
.toLowerCase()
.replaceAll(/[\s,.-]/g, '');
}
/**
* Adds a new spelling of Sault Ste. Marie to the list of checked spellings.
* @param newSpelling - A new spelling of Sault Ste. Marie.
*/
export function addSaultSteMarieSpelling(newSpelling) {
lowerCaseSaultSteMarieSpellings.add(sanitizeSpelling(newSpelling));
}
/**
* Determines whether a word is a spelling of Sault Ste. Marie.
* @param possibleSpelling - A possible spelling of Sault Ste. Marie.
* @returns `true` if the possible spelling appears to be a spelling of Sault Ste. Marie.
*/
export function isSaultSteMarie(possibleSpelling) {
return lowerCaseSaultSteMarieSpellings.has(sanitizeSpelling(possibleSpelling));
}
/**
* Returns the preferred spelling of Sault Ste. Marie.
* @param possibleSpelling - A possible spelling of Sault Ste. Marie.
* @param preferredSpelling - The preferred spelling of Sault Ste. Marie.
* @returns The preferred spelling if the possible spelling is a spelling of Sault Ste. Marie. Otherwise, the possible spelling is returned.
*/
export function fixSaultSteMarie(possibleSpelling, preferredSpelling = preferredSaultSteMarieSpelling) {
if (isSaultSteMarie(possibleSpelling)) {
return preferredSpelling;
}
return possibleSpelling;
}
export { preferredSaultSteMarieSpelling, canadaPostSaultSteMarieSpelling, lowerCaseSaultSteMarieSpellings } from './spellings.js';
export default {
addSaultSteMarieSpelling,
isSaultSteMarie,
fixSaultSteMarie,
preferredSaultSteMarieSpelling,
canadaPostSaultSteMarieSpelling,
lowerCaseSaultSteMarieSpellings
};