use set lookup to keep track of loaded modes

main
briandennis 7 years ago committed by Brian Dennis
parent f3b80b1783
commit 93c0214081

@ -300,14 +300,14 @@ const unfold = (f, seed) => {
}` }`
if (typeof window !== 'undefined' && typeof window.navigator !== 'undefined') { if (typeof window !== 'undefined' && typeof window.navigator !== 'undefined') {
const required = [] const alreadyLoaded = new Set()
LANGUAGES.filter(language => language.mode !== 'auto').forEach(language => { LANGUAGES.filter(language => language.mode !== 'auto').forEach(language => {
if (language.mode && required.indexOf(language.mode) === -1) { if (language.mode && !alreadyLoaded.has(language.mode)) {
required.push(language.mode) alreadyLoaded.add(language.mode)
!language.custom language.custom
? require(`codemirror/mode/${language.mode}/${language.mode}`) ? require(`./customModes/${language.mode}`)
: require(`./customModes/${language.mode}`) : require(`codemirror/mode/${language.mode}/${language.mode}`)
} }
}) })
} }

Loading…
Cancel
Save