Преглед на файлове

feat: .get() and .has() now use promises

Signed-off-by: Jonathan <theflametrooper@gmail.com>
Jonathan преди 5 години
родител
ревизия
35337e0c11
променени са 2 файла, в които са добавени 12 реда и са изтрити 553 реда
  1. 5 546
      dist/lofig.min.js
  2. 7 7
      lofig.js

Файловите разлики са ограничени, защото са твърде много
+ 5 - 546
dist/lofig.min.js


+ 7 - 7
lofig.js

@@ -3,8 +3,8 @@ import 'whatwg-fetch';
 
 window.lofig = {
 	folder: 'config/default.json',
-	get: (query, callback) => {
-		fetch(lofig.folder)
+	get: query => {
+		return fetch(lofig.folder)
 			.then(response => {
 				return response.json();
 			}).then(json => {
@@ -12,14 +12,14 @@ window.lofig = {
 				return Promise.each(query, property => {
 					json = json[property];
 				}).then(() => {
-					callback(json);
+					return json;
 				});
 			}).catch(err => {
 				console.log('parsing failed', err);
 			});
 	},
-	has: (query, callback) => {
-		fetch(lofig.folder)
+	has: query => {
+		return fetch(lofig.folder)
 			.then(response => {
 				return response.json();
 			}).then(json => {
@@ -27,8 +27,8 @@ window.lofig = {
 				return Promise.each(query, property => {
 					json = json[property];
 				}).then(() => {
-					if (json) callback(true);
-					else callback(false);
+					if (json) return true;
+					else return false;
 				});
 			}).catch(err => {
 				console.log('parsing failed', err);

Някои файлове не бяха показани, защото твърде много файлове са промени