1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2026-02-13 16:45:46 +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

@@ -284,17 +284,17 @@ var CompletionContext = Class("CompletionContext", {
get longestSubstring() { return self.longestAllSubstring; },
get items() {
return Ary.flatten(self.activeContexts.map(function m(context) {
return self.activeContexts.flatMap(context => {
let prefix = self.value.substring(minStart, context.offset);
return context.items.map(function m(item) {
return context.items.map(item => {
return {
text: prefix + item.text,
result: prefix + item.result,
__proto__: item
};
});
}));
});
}
});
@@ -323,24 +323,23 @@ var CompletionContext = Class("CompletionContext", {
* Possibly.
*/
let substrings = lists.reduce(
function r(res, list) {
return res.filter(function f(str) {
return list.some(function s_(s) {
return s.substr(0, str.length) == str;
});
(res, list) => {
return res.filter(str => {
return list.some(s => s.substr(0, str.length) == str);
});
},
lists.pop());
if (!substrings) // FIXME: How is this undefined?
return [];
return Ary.uniq(Array.slice(substrings));
},
// Temporary
get longestAllSubstring() {
return this.allSubstrings.reduce(function r(a, b) {
return a.length > b.length ? a : b, "";
});
return a.length > b.length ? a : b;
}, "");
},
get caret() { return this._caret - this.offset; },