refactored code and added win/lose popups
This commit is contained in:
@@ -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
|
||||
};
|
||||
Reference in New Issue
Block a user