Skip to content
This repository has been archived by the owner on Jun 23, 2020. It is now read-only.

Commit

Permalink
Drop the use of range, as newer constructs make it mainly unnecessary.
Browse files Browse the repository at this point in the history
  • Loading branch information
Standard8 committed May 7, 2020
1 parent c1b84f6 commit 61d73c5
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 34 deletions.
3 changes: 1 addition & 2 deletions compose.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ const {
escapeHtml,
getDefaultIdentity,
getIdentities,
range,
systemCharset,
} = importRelative(this, "misc.js");
const { msgHdrGetUri, getMail3Pane, msgHdrGetHeaders } = importRelative(
Expand Down Expand Up @@ -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);
Expand Down
26 changes: 1 addition & 25 deletions misc.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ var EXPORTED_SYMBOLS = [
"getIdentities",
"getDefaultIdentity",
"getIdentityForEmail",
// JS programming helpers
"range",
// Various formatting helpers
"dateAsInMessageList",
"escapeHtml",
Expand All @@ -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 }
*/
Expand Down Expand Up @@ -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
Expand Down
13 changes: 6 additions & 7 deletions send.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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;
}

Expand All @@ -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;
}
Expand Down

0 comments on commit 61d73c5

Please sign in to comment.