From aa5deedbc9e662c5e60e9ace4a5b1ef03d477e5c Mon Sep 17 00:00:00 2001 From: KDSBrowne Date: Mon, 28 May 2018 07:24:03 -0700 Subject: [PATCH] replace structural loop with reduce --- .../imports/startup/server/index.js | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/bigbluebutton-html5/imports/startup/server/index.js b/bigbluebutton-html5/imports/startup/server/index.js index 3d44e12951..059ba7dd28 100755 --- a/bigbluebutton-html5/imports/startup/server/index.js +++ b/bigbluebutton-html5/imports/startup/server/index.js @@ -25,20 +25,19 @@ WebApp.connectHandlers.use('/locale', (req, res) => { const browserLocale = req.query.locale.split(/[-_]/g); const localeList = [fallback]; - let getAvailableLocales = fs.readdirSync('assets/app/locales'); + const getAvailableLocales = fs.readdirSync('assets/app/locales'); let regionDefault = null; const usableLocales = []; - getAvailableLocales = getAvailableLocales + getAvailableLocales .map(file => file.replace('.json', '')) .map(locale => ( locale - )); - - for (let i = 0; i < getAvailableLocales.length; i += 1) { - if (getAvailableLocales[i] === browserLocale[0]) regionDefault = getAvailableLocales[i]; - if (getAvailableLocales[i].match(browserLocale[0])) usableLocales.push(getAvailableLocales[i]); - } + )) + .reduce((i, locale) => { + if (locale === browserLocale[0]) regionDefault = locale; + if (locale.match(browserLocale[0])) usableLocales.push(locale); + }, 0); if (regionDefault) localeList.push(regionDefault); if (!regionDefault && usableLocales[0]) localeList.push(usableLocales[0]);