Changeset f440ee


Ignore:
Timestamp:
Apr 5, 2017, 3:57:40 PM (4 years ago)
Author:
rene <rene@…>
Branches:
ng_0.9
Children:
647573
Parents:
3819a1
Message:

expression closures are deprecated

File:
1 edited

Legend:

Unmodified
Added
Removed
  • modules/stdlib/msgHdrUtils.js

    r3819a1 rf440ee  
    8686 * @return {String}
    8787 */
    88 function msgHdrGetUri(aMsg)
    89 aMsg.folder.getUriForMsg(aMsg)
     88function msgHdrGetUri(aMsg) {
     89    return aMsg.folder.getUriForMsg(aMsg);
     90}
    9091
    9192/**
     
    109110 * @return {bool}
    110111 */
    111 function msgHdrIsInbox(msgHdr)
    112 msgHdr.folder.getFlag(nsMsgFolderFlags_Inbox)
     112function msgHdrIsInbox(msgHdr) {
     113    return msgHdr.folder.getFlag(nsMsgFolderFlags_Inbox);
     114}
    113115
    114116/**
     
    117119 * @return {bool}
    118120 */
    119 function msgHdrIsDraft(msgHdr)
    120 msgHdr.folder.getFlag(nsMsgFolderFlags_Drafts)
     121function msgHdrIsDraft(msgHdr) {
     122    return msgHdr.folder.getFlag(nsMsgFolderFlags_Drafts);
     123}
    121124
    122125/**
     
    125128 * @return {bool}
    126129 */
    127 function msgHdrIsSent(msgHdr)
    128 msgHdr.folder.getFlag(nsMsgFolderFlags_SentMail)
     130function msgHdrIsSent(msgHdr) {
     131    return msgHdr.folder.getFlag(nsMsgFolderFlags_SentMail);
     132}
    129133
    130134/**
     
    133137 * @return {bool}
    134138 */
    135 function msgHdrIsArchive(msgHdr)
    136 msgHdr.folder.getFlag(nsMsgFolderFlags_Archive)
     139function msgHdrIsArchive(msgHdr) {
     140    return msgHdr.folder.getFlag(nsMsgFolderFlags_Archive);
     141}
    137142
    138143/**
     
    141146 * @return {nsIMsgDbHdr} The message header.
    142147 */
    143 function msgHdrFromNeckoUrl(aUrl)
    144 aUrl.QueryInterface(Ci.nsIMsgMessageUrl).messageHeader
     148function msgHdrFromNeckoUrl(aUrl) {
     149    return aUrl.QueryInterface(Ci.nsIMsgMessageUrl).messageHeader;
     150}
    145151
    146152/**
     
    214220  let oldTagList = msgHdrGetTags(aMsgHdr);
    215221  let oldTags = {}; // hashmap
    216   for each(let [, tag] in Iterator(oldTagList))
    217   oldTags[tag.key] = null;
     222 
     223  oldTagList.map(tag => oldTags[tag.key] = null);
    218224
    219225  let newTags = {};
    220226  let newTagList = aTags;
    221   for each(let [, tag] in Iterator(newTagList))
    222   newTags[tag.key] = null;
     227
     228  newTagList.map(tag => newTags[tag.key] = null);
    223229
    224230  let toAdd = newTagList.map(function(x) {if (!(x.key in oldTags)) return x.key});
     
    240246function msgHdrsMarkAsRead(msgHdrs, read) {
    241247  let pending = {};
    242   for each(let msgHdr in msgHdrs) {
     248 
     249  for (let msgHdr of Object.values(msgHdrs)) {
    243250    if (msgHdr.isRead == read)
    244251      continue;
     
    251258    pending[msgHdr.folder.URI].msgs.appendElement(msgHdr, false);
    252259  }
    253   for each(let {
     260  for (let {
    254261    folder, msgs
    255   } in pending) {
     262  } of Object.values(pending)) {
    256263    folder.markMessagesRead(msgs, read);
    257264    folder.msgDatabase = null; /* don't leak */
     
    265272function msgHdrsDelete(msgHdrs) {
    266273  let pending = {};
    267   for each(let msgHdr in msgHdrs) {
     274  for (let msgHdr of Object.values(msgHdrs)) {
    268275    if (!pending[msgHdr.folder.URI]) {
    269276      pending[msgHdr.folder.URI] = {
     
    274281    pending[msgHdr.folder.URI].msgs.appendElement(msgHdr, false);
    275282  }
    276   for each(let {
     283  for (let {
    277284    folder, msgs
    278   } in pending) {
     285  } of Object.values(pending)) {
    279286    folder.deleteMessages(msgs, getMail3Pane().msgWindow, false, false, null, true);
    280287    folder.msgDatabase = null; /* don't leak */
     
    307314  let batchMover = new mail3PaneWindow.BatchMessageMover();
    308315  batchMover.archiveMessages(msgHdrs.filter(
    309     function (x) !msgHdrIsArchive(x) && getMail3Pane().getIdentityForHeader(x).archiveEnabled
     316    function (x) {
     317        return !msgHdrIsArchive(x) && getMail3Pane().getIdentityForHeader(x).archiveEnabled;
     318    }
    310319  ));
    311320}
     
    316325 * @return {Bool}
    317326 */
    318 function msgHdrIsRss(msgHdr)
    319   (msgHdr.folder.server instanceof Ci.nsIRssIncomingServer)
     327function msgHdrIsRss(msgHdr) {
     328  return (msgHdr.folder.server instanceof Ci.nsIRssIncomingServer);
     329}
    320330
    321331/**
     
    324334 * @return {Bool}
    325335 */
    326 function msgHdrIsNntp(msgHdr)
    327   (msgHdr.folder.server instanceof Ci.nsINntpIncomingServer)
     336function msgHdrIsNntp(msgHdr) {
     337  return (msgHdr.folder.server instanceof Ci.nsINntpIncomingServer);
     338}
    328339
    329340/**
     
    332343 * @return {Bool}
    333344 */
    334 function msgHdrIsJunk(aMsgHdr)
    335 aMsgHdr.getStringProperty("junkscore") == Ci.nsIJunkMailPlugin.IS_SPAM_SCORE
     345function msgHdrIsJunk(aMsgHdr) {
     346    return aMsgHdr.getStringProperty("junkscore") == Ci.nsIJunkMailPlugin.IS_SPAM_SCORE;
     347}
    336348
    337349/**
     
    385397  let messageService = MailServices.messenger.messageServiceFromURI(uri);
    386398
    387   let fallback = function ()
    388   MsgHdrToMimeMessage(aMsgHdr, null, function (aMsgHdr, aMimeMsg) {
    389     k(aMimeMsg);
    390   }, true, {
    391     partsOnDemand: true,
    392   });
     399  let fallback = function () {
     400    return MsgHdrToMimeMessage(aMsgHdr, null, function (aMsgHdr, aMimeMsg) {
     401        k(aMimeMsg);
     402    }, true, {
     403        partsOnDemand: true,
     404    });
     405  }
    393406
    394407  // This is intentionally disabled because there's a bug in Thunderbird that
     
    401414        let lines = str.split(/\r?\n/);
    402415        let obj = {};
    403         for each(let [, line] in Iterator(lines)) {
     416        lines.map(function(line) {
    404417          let i = line.indexOf(":");
    405           if (i < 0)
    406             continue;
    407           let k = line.substring(0, i).toLowerCase();
    408           let v = line.substring(i + 1).trim();
    409           if (!(k in obj))
    410             obj[k] = [];
    411           obj[k].push(v);
    412         }
     418          if (i >= 0) {
     419            let k = line.substring(0, i).toLowerCase();
     420            let v = line.substring(i + 1).trim();
     421            if (!(k in obj))
     422                obj[k] = [];
     423            obj[k].push(v);
     424          }
     425        });
    413426        k(new HeaderHandler(obj));
    414427      }), null, true);
Note: See TracChangeset for help on using the changeset viewer.