Migrate to private class properties/methods
This commit is contained in:
parent
7dbe57084b
commit
aa9f53df57
100 changed files with 3795 additions and 3944 deletions
|
@ -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);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue