From c038e73471c65bd7f0055d808ee1d20c47684e7b Mon Sep 17 00:00:00 2001 From: Kris Maglione Date: Tue, 7 Oct 2008 21:23:18 +0000 Subject: [PATCH] Replace template.map2 with an overloaded template.map --- content/editor.js | 2 +- content/events.js | 2 +- content/options.js | 2 +- content/template.js | 16 ++++++++-------- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/content/editor.js b/content/editor.js index 0210f125..3b70272d 100644 --- a/content/editor.js +++ b/content/editor.js @@ -931,7 +931,7 @@ liberator.Editor = function () //{{{ let list = { - 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 : diff --git a/content/events.js b/content/events.js index e3bf5499..8d996d64 100644 --- a/content/events.js +++ b/content/events.js @@ -233,7 +233,7 @@ liberator.AutoCommands = function () //{{{ { - liberator.template.map2(cmds, function (event, items) + liberator.template.map(cmds, function (event, items) diff --git a/content/options.js b/content/options.js index a9edfc40..fe9aceb0 100644 --- a/content/options.js +++ b/content/options.js @@ -284,7 +284,7 @@ liberator.Options = function () //{{{ var str =
----- Auto Commands -----
{event}
{ - liberator.template.map2(liberator.globalVariables, function (i, value) { + liberator.template.map(liberator.globalVariables, function (i, value) { let prefix = typeof value == "number" ? "#" : typeof value == "function" ? "*" : " "; diff --git a/content/template.js b/content/template.js index b7ebda84..b47b6c62 100644 --- a/content/template.js +++ b/content/template.js @@ -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 = { { - this.map2(elems, function (idx, val) + this.map(elems, function (idx, val) @@ -207,7 +207,7 @@ liberator.template = { this.map(iter, function (row) { - liberator.template.map2(row, function (i, d) + liberator.template.map(row, function (i, d) ) } )
jumptitleURI
{idx == index ? ">" : ""} {Math.abs(idx - index)}
{d}