refactored code and added win/lose popups

This commit is contained in:
Nathan DECHER
2020-04-05 16:14:39 +02:00
parent 40ec4fa09a
commit 4746f34537
6 changed files with 353 additions and 146 deletions
+18
View File
@@ -0,0 +1,18 @@
const cache=Object.create(null);
const get=async filename => {
if(cache[filename]) return cache[filename];
const req=await fetch('levels/'+filename);
const json=await req.json();
return cache[filename]=json;
};
const clearCache=() =>
Object
.keys(cache)
.forEach(key => delete cache[key]);
return module.exports={
get,
clearCache
};