|  | @@ -1,35 +1,42 @@
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |  window.lofig = {
 | 
	
		
			
				|  |  |  	folder: '/config/default.json',
 | 
	
		
			
				|  |  | -	get: (query, cb) => {
 | 
	
		
			
				|  |  | -		return fetch(lofig.folder)
 | 
	
		
			
				|  |  | -			.then(response => {
 | 
	
		
			
				|  |  | -				return response.json();
 | 
	
		
			
				|  |  | -			}).then(json => {
 | 
	
		
			
				|  |  | -				query.split('.')
 | 
	
		
			
				|  |  | -					.forEach(property => {
 | 
	
		
			
				|  |  | -						json = json[property];
 | 
	
		
			
				|  |  | -					});
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -				if (cb) return cb(json);
 | 
	
		
			
				|  |  | -				else return json;
 | 
	
		
			
				|  |  | -			}).catch(err => {
 | 
	
		
			
				|  |  | -				console.log('parsing failed', err);
 | 
	
		
			
				|  |  | +	config: null,
 | 
	
		
			
				|  |  | +	fetchConfig: async () => {
 | 
	
		
			
				|  |  | +		if (!lofig.config) {
 | 
	
		
			
				|  |  | +			const response = await fetch(lofig.folder);
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +			if (!response.ok) {
 | 
	
		
			
				|  |  | +				const message = `An error has occured: ${response.status}`;
 | 
	
		
			
				|  |  | +				throw new Error(message);
 | 
	
		
			
				|  |  | +			}
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +			lofig.config = response.json();
 | 
	
		
			
				|  |  | +		}
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +		return lofig.config;
 | 
	
		
			
				|  |  | +	},
 | 
	
		
			
				|  |  | +	get: async (query, cb) => {
 | 
	
		
			
				|  |  | +		let json = await lofig.fetchConfig();
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +		query.split('.')
 | 
	
		
			
				|  |  | +			.forEach(property => {
 | 
	
		
			
				|  |  | +				json = json[property];
 | 
	
		
			
				|  |  |  			});
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +		if (cb) return cb(json);
 | 
	
		
			
				|  |  | +		return json;
 | 
	
		
			
				|  |  |  	},
 | 
	
		
			
				|  |  | -	has: (query, cb) => {
 | 
	
		
			
				|  |  | -		return fetch(lofig.folder)
 | 
	
		
			
				|  |  | -			.then(response => {
 | 
	
		
			
				|  |  | -				return response.json();
 | 
	
		
			
				|  |  | -			}).then(json => {
 | 
	
		
			
				|  |  | -				query.split('.')
 | 
	
		
			
				|  |  | -					.forEach(property => {
 | 
	
		
			
				|  |  | -						json = json[property];
 | 
	
		
			
				|  |  | -					});
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -				if (cb) return cb(json);
 | 
	
		
			
				|  |  | -				return json;
 | 
	
		
			
				|  |  | -			}).catch(err => {
 | 
	
		
			
				|  |  | -				console.log('parsing failed', err);
 | 
	
		
			
				|  |  | +	has: async (query, cb) => {
 | 
	
		
			
				|  |  | +		let json = await lofig.fetchConfig();
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +		query.split('.')
 | 
	
		
			
				|  |  | +			.forEach(property => {
 | 
	
		
			
				|  |  | +				json = json[property];
 | 
	
		
			
				|  |  |  			});
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +		if (cb) return cb(!!json);
 | 
	
		
			
				|  |  | +		return !!json;
 | 
	
		
			
				|  |  |  	}
 | 
	
		
			
				|  |  |  };
 |