mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2025-12-23 07:17:59 +01:00
Replace template.map2 with an overloaded template.map
This commit is contained in:
@@ -931,7 +931,7 @@ liberator.Editor = function () //{{{
|
||||
let list =
|
||||
<table>
|
||||
{
|
||||
liberator.template.map2(abbrev, function (lhs, rhs)
|
||||
liberator.template.map(abbrev, function (lhs, rhs)
|
||||
liberator.template.map(rhs, function (abbr)
|
||||
searchFilter.indexOf(abbr[0]) < 0 ? undefined :
|
||||
<tr>
|
||||
|
||||
@@ -233,7 +233,7 @@ liberator.AutoCommands = function () //{{{
|
||||
<td class="hl-Title" colspan="2">----- Auto Commands -----</td>
|
||||
</tr>
|
||||
{
|
||||
liberator.template.map2(cmds, function (event, items)
|
||||
liberator.template.map(cmds, function (event, items)
|
||||
<tr>
|
||||
<td class="hl-Title" colspan="2">{event}</td>
|
||||
</tr>
|
||||
|
||||
@@ -284,7 +284,7 @@ liberator.Options = function () //{{{
|
||||
var str =
|
||||
<table>
|
||||
{
|
||||
liberator.template.map2(liberator.globalVariables, function (i, value) {
|
||||
liberator.template.map(liberator.globalVariables, function (i, value) {
|
||||
let prefix = typeof value == "number" ? "#" :
|
||||
typeof value == "function" ? "*" :
|
||||
" ";
|
||||
|
||||
@@ -5,7 +5,12 @@ liberator.template = {
|
||||
|
||||
map: function (iter, fn, sep)
|
||||
{
|
||||
if (iter.length) /* Kludge? */
|
||||
if (fn.length > 1)
|
||||
{
|
||||
iter = Iterator(iter);
|
||||
fn = function (x) fn.apply(null, x);
|
||||
}
|
||||
else if (iter.length) /* Kludge? */
|
||||
iter = liberator.util.arrayIter(iter);
|
||||
let ret = <></>;
|
||||
let n = 0;
|
||||
@@ -20,11 +25,6 @@ liberator.template = {
|
||||
}
|
||||
return ret;
|
||||
},
|
||||
map2: function (iter, fn, sep)
|
||||
{
|
||||
// Could cause performance problems.
|
||||
return this.map(Iterator(iter), function (x) fn.apply(null, x), sep);
|
||||
},
|
||||
|
||||
maybeXML: function (xml)
|
||||
{
|
||||
@@ -143,7 +143,7 @@ liberator.template = {
|
||||
<th colspan="2">jump</th><th>title</th><th>URI</th>
|
||||
</tr>
|
||||
{
|
||||
this.map2(elems, function (idx, val)
|
||||
this.map(elems, function (idx, val)
|
||||
<tr>
|
||||
<td class="indicator">{idx == index ? ">" : ""}</td>
|
||||
<td>{Math.abs(idx - index)}</td>
|
||||
@@ -207,7 +207,7 @@ liberator.template = {
|
||||
this.map(iter, function (row)
|
||||
<tr>
|
||||
{
|
||||
liberator.template.map2(row, function (i, d)
|
||||
liberator.template.map(row, function (i, d)
|
||||
<td style={style[i] || ""}>{d}</td>)
|
||||
}
|
||||
</tr>)
|
||||
|
||||
Reference in New Issue
Block a user