Use Map instead of Object

This commit is contained in:
Giuseppe Criscione 2023-12-26 12:15:51 +01:00
parent 4242711864
commit 40ef6408a7
2 changed files with 5 additions and 5 deletions

File diff suppressed because one or more lines are too long

View File

@ -1,10 +1,10 @@
import { app } from "../app";
const cache = {};
const cache = new Map();
export function passIcon(icon, callback) {
if (icon in cache) {
callback(cache[icon]);
if (cache.has(icon)) {
callback(cache.get(icon));
return;
}
@ -13,7 +13,7 @@ export function passIcon(icon, callback) {
request.onload = function () {
const data = this.status === 200 ? this.response : "";
if (data !== "") {
cache[icon] = data;
cache.set(icon, data);
}
callback(data);
};