summaryrefslogtreecommitdiff
path: root/common/modules/config.jsm
diff options
context:
space:
mode:
authorKris Maglione <maglione.k@gmail.com>2015-12-20 02:02:54 -0800
committerKris Maglione <maglione.k@gmail.com>2015-12-20 02:02:54 -0800
commit27cdeb18853232a8c24a83b80bcaef19b1d1b671 (patch)
treeae22dab25f451f1354070a0b906e3e9af85b91ef /common/modules/config.jsm
parent65725c95164c6da1fe5bedbeafa651c06d08b72e (diff)
downloadpentadactyl-27cdeb18853232a8c24a83b80bcaef19b1d1b671.tar.gz
ES6-ify some things. Still a long way to go...
Diffstat (limited to 'common/modules/config.jsm')
-rw-r--r--common/modules/config.jsm26
1 files changed, 15 insertions, 11 deletions
diff --git a/common/modules/config.jsm b/common/modules/config.jsm
index aa8d842e..c73cd0e5 100644
--- a/common/modules/config.jsm
+++ b/common/modules/config.jsm
@@ -235,20 +235,19 @@ var ConfigBase = Class("ConfigBase", {
let uri = "resource://dactyl-locale/";
let jar = io.isJarURL(uri);
+ let res;
if (jar) {
let prefix = getDir(jar.JAREntry);
- var res = iter(s.slice(prefix.length).replace(/\/.*/, "")
- for (s of io.listJar(jar.JARFile, prefix)))
- .toArray();
+ res = Array.from(io.listJar(jar.JARFile, prefix),
+ s => slice(prefix.length).replace(/\/.*/, ""));
}
else {
- res = Ary(f.leafName
- // Fails on FF3: for (f of util.getFile(uri).iterDirectory())
- for (f of util.getFile(uri).readDirectory())
- if (f.isDirectory())).array;
+ res = Array.from(util.getFile(uri).readDirectory())
+ .filter(f => f.isDirectory())
+ .map(f => f.leafName);
}
- let exists = function exists(pkg) {
+ let exists = pkg => {
return services["resource:"].hasSubstitution("dactyl-locale-" + pkg);
};
@@ -265,9 +264,14 @@ var ConfigBase = Class("ConfigBase", {
* @returns {string}
*/
bestLocale: function (list) {
- return values([this.appLocale, this.appLocale.replace(/-.*/, ""),
- "en", "en-US", list[0]])
- .find(bind("has", new RealSet(list)));
+ let candidates = [this.appLocale,
+ this.appLocale.replace(/-.*/, ""),
+ "en",
+ "en-US",
+ list[0]];
+
+ list = new RealSet(list);
+ return candidates.find(locale => list.has(locale));
},
/**