mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2026-02-16 19:25:46 +01:00
Use builtin Array.find rather than array.nth where applicable.
This commit is contained in:
@@ -105,7 +105,7 @@ var AbbrevHive = Class("AbbrevHive", Contexts.Hive, {
|
||||
},
|
||||
|
||||
/** @property {boolean} True if there are no abbreviations. */
|
||||
get empty() !values(this._store).nth(util.identity, 0),
|
||||
get empty() !values(this._store).find(util.identity),
|
||||
|
||||
/**
|
||||
* Adds a new abbreviation.
|
||||
@@ -251,7 +251,7 @@ var Abbreviations = Module("abbreviations", {
|
||||
let match = this._match.exec(text);
|
||||
if (match)
|
||||
return this.hives.map(h => h.get(mode, match[2] || match[4] || match[6]))
|
||||
.nth(util.identity, 0);
|
||||
.find(util.identity);
|
||||
return null;
|
||||
},
|
||||
|
||||
|
||||
@@ -2018,7 +2018,7 @@ var ItemList = Class("ItemList", {
|
||||
if (start < 0 || start >= this.itemCount)
|
||||
return null;
|
||||
|
||||
group = array.nth(groups, g => let (i = start - g.offsets.start) i >= 0 && i < g.itemCount, 0);
|
||||
group = groups.find(g => let (i = start - g.offsets.start) i >= 0 && i < g.itemCount);
|
||||
return [group.context, start - group.offsets.start];
|
||||
},
|
||||
|
||||
|
||||
@@ -1299,16 +1299,21 @@ var Hints = Module("hints", {
|
||||
},
|
||||
{
|
||||
keepQuotes: true,
|
||||
|
||||
getKey: function (val, default_)
|
||||
let (res = array.nth(this.value, re => let (match = re.exec(val)) match && match[0] == val, 0))
|
||||
res ? res.matcher : default_,
|
||||
let (res = this.value.find(re => let (match = re.exec(val)) match && match[0] == val))
|
||||
res ? res.matcher
|
||||
: default_,
|
||||
|
||||
parse: function parse(val) {
|
||||
let vals = parse.supercall(this, val);
|
||||
for (let value in values(vals))
|
||||
value.matcher = DOM.compileMatcher(Option.splitList(value.result));
|
||||
return vals;
|
||||
},
|
||||
|
||||
testValues: function testValues(vals, validator) vals.every(re => Option.splitList(re).every(validator)),
|
||||
|
||||
validator: DOM.validateMatcher
|
||||
});
|
||||
|
||||
|
||||
@@ -274,7 +274,8 @@ var Modes = Module("modes", {
|
||||
remove: function remove(mode, covert) {
|
||||
if (covert && this.topOfStack.main != mode) {
|
||||
util.assert(mode != this.NORMAL);
|
||||
for (let m; m = array.nth(this.modeStack, m => m.main == mode, 0);)
|
||||
|
||||
for (let m; m = this.modeStack.find(m => m.main == mode);)
|
||||
this._modeStack.splice(this._modeStack.indexOf(m));
|
||||
}
|
||||
else if (this.stack.some(m => m.main == mode)) {
|
||||
@@ -604,7 +605,7 @@ var Modes = Module("modes", {
|
||||
|
||||
getKey: function getKey(val, default_) {
|
||||
if (isArray(val))
|
||||
return (array.nth(this.value, v => val.some(m => m.name === v.mode), 0)
|
||||
return (this.value.find(v => val.some(m => m.name === v.mode))
|
||||
|| { result: default_ }).result;
|
||||
|
||||
return hasOwnProperty(this.valueMap, val) ? this.valueMap[val] : default_;
|
||||
|
||||
@@ -550,7 +550,7 @@ var Tabs = Module("tabs", {
|
||||
if (matches)
|
||||
return tabs.select(this.allTabs[parseInt(matches[1], 10) - 1], false);
|
||||
|
||||
matches = array.nth(tabs.allTabs, t => (t.linkedBrowser.lastURI || {}).spec === buffer, 0);
|
||||
matches = tabs.allTabs.find(t => (t.linkedBrowser.lastURI || {}).spec === buffer);
|
||||
if (matches)
|
||||
return tabs.select(matches, false);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user