Migrate to private class properties/methods

This commit is contained in:
Jamie Kyle 2025-01-14 11:11:52 -08:00 committed by GitHub
commit aa9f53df57
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
100 changed files with 3795 additions and 3944 deletions

View file

@ -34,9 +34,9 @@ type EmojiEntryType = Readonly<{
type SheetCacheEntry = Map<string, Uint8Array>;
export class EmojiService {
private readonly emojiMap = new Map<string, EmojiEntryType>();
readonly #emojiMap = new Map<string, EmojiEntryType>();
private readonly sheetCache = new LRUCache<string, SheetCacheEntry>({
readonly #sheetCache = new LRUCache<string, SheetCacheEntry>({
// Each sheet is roughly 500kb
max: 10,
});
@ -52,12 +52,12 @@ export class EmojiService {
return new Response('invalid', { status: 400 });
}
return this.fetch(emoji);
return this.#fetch(emoji);
});
for (const [sheet, emojiList] of Object.entries(manifest)) {
for (const utf16 of emojiList) {
this.emojiMap.set(utf16ToEmoji(utf16), { sheet, utf16 });
this.#emojiMap.set(utf16ToEmoji(utf16), { sheet, utf16 });
}
}
}
@ -71,15 +71,15 @@ export class EmojiService {
return new EmojiService(resourceService, manifest);
}
private async fetch(emoji: string): Promise<Response> {
const entry = this.emojiMap.get(emoji);
async #fetch(emoji: string): Promise<Response> {
const entry = this.#emojiMap.get(emoji);
if (!entry) {
return new Response('entry not found', { status: 404 });
}
const { sheet, utf16 } = entry;
let imageMap = this.sheetCache.get(sheet);
let imageMap = this.#sheetCache.get(sheet);
if (!imageMap) {
const proto = await this.resourceService.getData(
`emoji-sheet-${sheet}.proto`
@ -96,7 +96,7 @@ export class EmojiService {
image || new Uint8Array(0),
])
);
this.sheetCache.set(sheet, imageMap);
this.#sheetCache.set(sheet, imageMap);
}
const image = imageMap.get(utf16);