1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2026-01-04 09:54:11 +01:00

ES6-ify some things. Still a long way to go...

This commit is contained in:
Kris Maglione
2015-12-20 02:02:54 -08:00
parent 65725c9516
commit 27cdeb1885
28 changed files with 411 additions and 303 deletions

View File

@@ -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));
},
/**