Docs for getAlternateCodes

pull/196204/head
Daniel Imms 2023-11-27 11:39:00 -08:00
parent a62532894f
commit ab6a1b97f4
No known key found for this signature in database
GPG Key ID: E5CF412B63651C69
1 changed files with 12 additions and 1 deletions

View File

@ -136,13 +136,24 @@ function charactersMatch(codeA: number, codeB: number): boolean {
}
const alternateCharsCache: Map<number, ArrayLike<number> | undefined> = new Map();
/**
* Gets alternative codes to the character code passed in. This comes in the
* form of an array of character codes, all of which must match _in order_ to
* successfully match.
*
* @param code The character code to check.
*/
function getAlternateCodes(code: number): ArrayLike<number> | undefined {
if (alternateCharsCache.has(code)) {
return alternateCharsCache.get(code);
}
const codes = getKoreanAltChars(code);
// NOTE: This function is written in such a way that it can be extended in
// the future, but right now the return type takes into account it's only
// supported by a single "alt codes provider".
// `ArrayLike<ArrayLike<number>>` is a more appropriate type if changed.
let result: ArrayLike<number> | undefined;
const codes = getKoreanAltChars(code);
if (codes) {
result = codes;
}