Browse Source

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

Signed-off-by: Jonathan <theflametrooper@gmail.com>
Jonathan 5 years ago
parent
commit
35337e0c11
2 changed files with 12 additions and 553 deletions
  1. 5 546
      dist/lofig.min.js
  2. 7 7
      lofig.js

File diff suppressed because it is too large
+ 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);

Some files were not shown because too many files changed in this diff