From 61d73c5fae7b65392ada874e89aa22591c42294e Mon Sep 17 00:00:00 2001 From: Mark Banner Date: Thu, 7 May 2020 09:01:34 +0100 Subject: [PATCH] Drop the use of range, as newer constructs make it mainly unnecessary. --- compose.js | 3 +-- misc.js | 26 +------------------------- send.js | 13 ++++++------- 3 files changed, 8 insertions(+), 34 deletions(-) diff --git a/compose.js b/compose.js index c54eb0d..01736e7 100644 --- a/compose.js +++ b/compose.js @@ -41,7 +41,6 @@ const { escapeHtml, getDefaultIdentity, getIdentities, - range, systemCharset, } = importRelative(this, "misc.js"); const { msgHdrGetUri, getMail3Pane, msgHdrGetHeaders } = importRelative( @@ -418,7 +417,7 @@ function replyAllParams(aIdentity, aMsgHdr, k) { if (emails.length) { // Invariant: at this stage, we only have one item in to. cc = cc.concat([to[0]]); // move the to in cc - to = [...range(0, names.length)].map(i => [names[i], emails[i]]); + to = names.map((n, i) => [n, emails[i]]); } } finish(to, cc, bcc); diff --git a/misc.js b/misc.js index c821b92..da19428 100644 --- a/misc.js +++ b/misc.js @@ -14,8 +14,6 @@ var EXPORTED_SYMBOLS = [ "getIdentities", "getDefaultIdentity", "getIdentityForEmail", - // JS programming helpers - "range", // Various formatting helpers "dateAsInMessageList", "escapeHtml", @@ -34,28 +32,6 @@ XPCOMUtils.defineLazyModuleGetters(this, { Services: "resource://gre/modules/Services.jsm", }); -if (!Services.intl) { - // That one doesn't belong to MailServices. - XPCOMUtils.defineLazyServiceGetter( - MailServices, - "i18nDateFormatter", - "@mozilla.org/intl/scriptabledateformat;1", - "nsIScriptableDateFormat" - ); -} - -/** - * Python-style range function to use in list comprehensions. - * @param {Number} begin - * @param {Number} end - * @return {Generator} An iterator that yields from begin to end - 1. - */ -function* range(begin, end) { - for (let i = begin; i < end; ++i) { - yield i; - } -} - /** * Returns the default identity in the form { boolean isDefault; nsIMsgIdentity identity } */ @@ -121,7 +97,7 @@ function getIdentityForEmail(anEmailAddress) { } /** - * A stupid formatting function that uses the i18nDateFormatter XPCOM component + * A stupid formatting function that uses Services.intl * to format a date just like in the message list * @param {Date} aDate a javascript Date object * @return {String} a string containing the formatted date diff --git a/send.js b/send.js index 1121d88..217a909 100644 --- a/send.js +++ b/send.js @@ -30,7 +30,6 @@ function importRelative(that, path) { return ChromeUtils.import(new URL(path, that.__URI__)); } -const { range } = importRelative(this, "misc.js"); const { msgUriToMsgHdr } = importRelative(this, "msgHdrUtils.js"); const { determineComposeHtml, @@ -244,9 +243,9 @@ function sendMessage( "Can't edit more than one message at a time" ); let msgHdr = msgUriToMsgHdr(urls[0]); - references = [...range(0, msgHdr.numReferences)].map(i => - msgHdr.getStringReference(i) - ); + for (let i = 0; i < msgHdr.numReferences; i++) { + references.push(msgHdr.getStringReference(i)); + } break; } @@ -262,9 +261,9 @@ function sendMessage( "Can't reply to more than one message at a time" ); let msgHdr = msgUriToMsgHdr(urls[0]); - references = [...range(0, msgHdr.numReferences)].map(i => - msgHdr.getStringReference(i) - ); + for (let i = 0; i < msgHdr.numReferences; i++) { + references.push(msgHdr.getStringReference(i)); + } references.push(msgHdr.messageId); break; }