From 9ff5dee9790cc7db87978c67be8b7a8cc389b79f Mon Sep 17 00:00:00 2001 From: coderaiser Date: Sat, 18 May 2019 17:49:56 +0300 Subject: [PATCH] refactor(files) early return --- client/dom/files.js | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/client/dom/files.js b/client/dom/files.js index 1c638275..08e6bf76 100644 --- a/client/dom/files.js +++ b/client/dom/files.js @@ -31,14 +31,11 @@ function getFile(name, callback) { switch(type) { case 'string': - getModule(name, callback); - break; + return getModule(name, callback); case 'array': array = unaryMap(name, get); - - exec.parallel(array, callback); - break; + return exec.parallel(array, callback); } } @@ -59,15 +56,14 @@ function getModule(name, callback) { const isHTML = regExpHTML.test(name); const isJSON = regExpJSON.test(name); - if (!isHTML && !isJSON) { - showError(name); - } else if (name === 'config') { - getConfig(callback); - } else { - path = getPath(name, isHTML, isJSON); - - getSystemFile(path, callback); - } + if (!isHTML && !isJSON) + return showError(name); + + if (name === 'config') + return getConfig(callback); + + path = getPath(name, isHTML, isJSON); + getSystemFile(path, callback); }