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
};
