From a82575a830bafbf9e71598f0e447a9f6d52a9da0 Mon Sep 17 00:00:00 2001 From: djmaze Date: Wed, 22 Jul 2020 20:09:31 +0200 Subject: [PATCH] Underscore.js _.map() to native Array.map() (optional with Object.entries/values) --- dev/App/Admin.js | 6 +++--- dev/App/User.js | 15 +++++++-------- dev/Component/AbstractRadio.js | 3 +-- dev/External/ko.js | 15 +++++++-------- dev/Model/Attachment.js | 2 +- dev/Model/Email.js | 2 +- dev/Model/Filter.js | 6 +++--- dev/Model/Message.js | 5 ++--- dev/Remote/User/Ajax.js | 4 +--- dev/Settings/Admin/Contacts.js | 2 +- dev/Settings/Admin/General.js | 2 +- dev/Settings/User/Filters.js | 2 +- dev/Settings/User/Themes.js | 3 +-- dev/Stores/User/Account.js | 2 +- dev/Stores/User/Folder.js | 2 +- dev/Stores/User/Identity.js | 2 +- dev/Stores/User/Message.js | 4 ++-- dev/Stores/User/Pgp.js | 14 +++++++------- dev/Stores/User/Template.js | 2 +- dev/View/Popup/Compose.js | 13 ++++++------- dev/View/Popup/ComposeOpenPgp.js | 16 ++++++++-------- dev/View/Popup/Contacts.js | 8 ++++---- dev/View/Popup/DomainAlias.js | 3 +-- dev/View/Popup/Languages.js | 3 +-- dev/View/Popup/Plugin.js | 2 +- dev/View/User/MailBox/MessageList.js | 2 +- dev/View/User/MailBox/MessageView.js | 6 +++--- 27 files changed, 68 insertions(+), 78 deletions(-) diff --git a/dev/App/Admin.js b/dev/App/Admin.js index 4d3e8c891..05d082378 100644 --- a/dev/App/Admin.js +++ b/dev/App/Admin.js @@ -40,7 +40,7 @@ class AdminApp extends AbstractApp { DomainStore.domains.loading(false); if (StorageResultType.Success === result && data && data.Result) { DomainStore.domains( - _.map(data.Result, ([enabled, alias], name) => ({ + Object.entries(data.Result).map(([enabled, alias], name) => ({ name: name, disabled: ko.observable(!enabled), alias: alias, @@ -57,7 +57,7 @@ class AdminApp extends AbstractApp { PluginStore.plugins.loading(false); if (StorageResultType.Success === result && data && data.Result) { PluginStore.plugins( - _.map(data.Result, (item) => ({ + data.Result.map(item => ({ name: item.Name, disabled: ko.observable(!item.Enabled), configured: ko.observable(!!item.Configured) @@ -87,7 +87,7 @@ class AdminApp extends AbstractApp { if (isArray(data.Result.List)) { list = _.compact( - _.map(data.Result.List, (item) => { + data.Result.List.map(item => { if (item) { item.loading = ko.observable(!isUnd(loading[item.file])); return 'core' === item.type && !item.canBeInstalled ? null : item; diff --git a/dev/App/User.js b/dev/App/User.js index 68a3c71e4..f956b270d 100644 --- a/dev/App/User.js +++ b/dev/App/User.js @@ -520,7 +520,7 @@ class AppUser extends AbstractApp { .getKeyId() .toHex() .toLowerCase(), - _.uniq(_.compact(_.map(oItem.getKeyIds(), (item) => (item && item.toHex ? item.toHex() : null)))), + _.uniq(_.compact(oItem.getKeyIds().map(item => (item && item.toHex ? item.toHex() : null)))), aUsers, aEmails, oItem.isPrivate(), @@ -590,9 +590,8 @@ class AppUser extends AbstractApp { delegateRunOnDestroy(AccountStore.accounts()); AccountStore.accounts( - _.map( - oData.Result.Accounts, - (sValue) => new AccountModel(sValue, sValue !== parentEmail, counts[sValue] || 0) + oData.Result.Accounts.map( + sValue => new AccountModel(sValue, sValue !== parentEmail, counts[sValue] || 0) ) ); } @@ -606,7 +605,7 @@ class AppUser extends AbstractApp { delegateRunOnDestroy(IdentityStore.identities()); IdentityStore.identities( - _.map(oData.Result.Identities, (identityData) => { + oData.Result.Identities.map(identityData => { const id = pString(identityData.Id), email = pString(identityData.Email), identity = new IdentityModel(id, email); @@ -636,7 +635,7 @@ class AppUser extends AbstractApp { TemplateStore.templates( _.compact( - _.map(data.Result.Templates, (templateData) => { + data.Result.Templates.map(templateData => { const template = new TemplateModel(); return template.parse(templateData) ? template : null; }) @@ -820,7 +819,7 @@ class AppUser extends AbstractApp { messages = MessageStore.messageListChecked(); } - rootUids = _.uniq(_.compact(_.map(messages, (oMessage) => (oMessage && oMessage.uid ? oMessage.uid : null)))); + rootUids = _.uniq(_.compact(messages.map(oMessage => (oMessage && oMessage.uid ? oMessage.uid : null)))); if ('' !== sFolderFullNameRaw && 0 < rootUids.length) { switch (iSetAction) { @@ -881,7 +880,7 @@ class AppUser extends AbstractApp { Remote.suggestions((result, data) => { if (StorageResultType.Success === result && data && isArray(data.Result)) { autocompleteCallback( - _.compact(_.map(data.Result, (item) => (item && item[0] ? new EmailModel(item[0], item[1]) : null))) + _.compact(data.Result.map(item => (item && item[0] ? new EmailModel(item[0], item[1]) : null))) ); } else if (StorageResultType.Abort !== result) { autocompleteCallback([]); diff --git a/dev/Component/AbstractRadio.js b/dev/Component/AbstractRadio.js index bb1bfeb69..28334400a 100644 --- a/dev/Component/AbstractRadio.js +++ b/dev/Component/AbstractRadio.js @@ -1,4 +1,3 @@ -import _ from '_'; import ko from 'ko'; import { isUnd } from 'Common/Utils'; import { AbstractComponent } from 'Component/Abstract'; @@ -21,7 +20,7 @@ class AbstractRadio extends AbstractComponent { this.readOnly = isUnd(params.readOnly) ? false : !!params.readOnly; if (params.values) { - this.values(_.map(params.values, (label, value) => ({ label: label, value: value }))); + this.values(Object.entries(params.values).map((label, value) => ({ label: label, value: value }))); } this.click = this.click.bind(this); diff --git a/dev/External/ko.js b/dev/External/ko.js index c5612a33d..109e79679 100644 --- a/dev/External/ko.js +++ b/dev/External/ko.js @@ -824,14 +824,13 @@ ko.bindingHandlers.emailsTags = { return null; }, parseHook: (input) => - _.map( - _.flatten( - _.map(input, (inputValue) => { - const values = EmailModel.parseEmailLine(inputValue); - return values.length ? values : inputValue; - }) - ), - (item) => (_.isObject(item) ? [item.toLine(false), item] : [item, null]) + _.flatten( + input.map(inputValue => { + const values = EmailModel.parseEmailLine(inputValue); + return values.length ? values : inputValue; + }) + ).map( + item => (_.isObject(item) ? [item.toLine(false), item] : [item, null]) ), change: (event) => { $el.data('EmailsTagsValue', event.target.value); diff --git a/dev/Model/Attachment.js b/dev/Model/Attachment.js index 941b53a4a..67b91ba59 100644 --- a/dev/Model/Attachment.js +++ b/dev/Model/Attachment.js @@ -187,7 +187,7 @@ export const staticCombinedIconClass = (data) => { if (isNonEmptyArray(data)) { result = 'icon-attachment'; - types = _.uniq(_.compact(_.map(data, (item) => (item ? staticFileType(getFileExtension(item[0]), item[1]) : '')))); + types = _.uniq(_.compact(data.map(item => (item ? staticFileType(getFileExtension(item[0]), item[1]) : '')))); if (types && 1 === types.length && types[0]) { switch (types[0]) { diff --git a/dev/Model/Email.js b/dev/Model/Email.js index 2bfa212d9..8fea3c865 100644 --- a/dev/Model/Email.js +++ b/dev/Model/Email.js @@ -185,7 +185,7 @@ class EmailModel { const parsedResult = addressparser(line); if (isNonEmptyArray(parsedResult)) { return _.compact( - _.map(parsedResult, (item) => + parsedResult.map(item => item.address ? new EmailModel(item.address.replace(/^[<]+(.*)[>]+$/g, '$1'), item.name || '') : null ) ); diff --git a/dev/Model/Filter.js b/dev/Model/Filter.js index c160dbc27..d1ed648d9 100644 --- a/dev/Model/Filter.js +++ b/dev/Model/Filter.js @@ -190,7 +190,7 @@ class FilterModel extends AbstractModel { Enabled: this.enabled() ? '1' : '0', Name: this.name(), ConditionsType: this.conditionsType(), - Conditions: _.map(this.conditions(), (item) => item.toJson()), + Conditions: this.conditions().map(item => item.toJson()), ActionValue: this.actionValue(), ActionValueSecond: this.actionValueSecond(), @@ -231,7 +231,7 @@ class FilterModel extends AbstractModel { if (isNonEmptyArray(json.Conditions)) { this.conditions( _.compact( - _.map(json.Conditions, (aData) => { + json.Conditions.map(aData => { const filterCondition = new FilterConditionModel(); return filterCondition && filterCondition.parse(aData) ? filterCondition : null; }) @@ -282,7 +282,7 @@ class FilterModel extends AbstractModel { filter.actionKeep(this.actionKeep()); filter.actionNoStop(this.actionNoStop()); - filter.conditions(_.map(this.conditions(), (item) => item.cloneSelf())); + filter.conditions(this.conditions().map(item => item.cloneSelf())); return filter; } diff --git a/dev/Model/Message.js b/dev/Model/Message.js index d0886e94a..d85486944 100644 --- a/dev/Model/Message.js +++ b/dev/Model/Message.js @@ -202,8 +202,7 @@ class MessageModel extends AbstractModel { getEmails(properties) { return _.compact( _.uniq( - _.map( - _.reduce(properties, (carry, property) => carry.concat(this[property]), []), + _.reduce(properties, (carry, property) => carry.concat(this[property]), []).map( (oItem) => (oItem ? oItem.email : '') ) ) @@ -628,7 +627,7 @@ class MessageModel extends AbstractModel { * @returns {string} */ attachmentsToStringLine() { - const attachLines = _.map(this.attachments(), (item) => item.fileName + ' (' + item.friendlySize + ')'); + const attachLines = this.attachments().map(item => item.fileName + ' (' + item.friendlySize + ')'); return attachLines && 0 < attachLines.length ? attachLines.join(', ') : ''; } diff --git a/dev/Remote/User/Ajax.js b/dev/Remote/User/Ajax.js index 33af9911d..7233f65ba 100644 --- a/dev/Remote/User/Ajax.js +++ b/dev/Remote/User/Ajax.js @@ -1,5 +1,3 @@ -import _ from '_'; - import { pString, pInt, isArray, trim, boolToAjax } from 'Common/Utils'; import { @@ -247,7 +245,7 @@ class RemoteUserAjax extends AbstractAjaxRemote { this.defaultRequest(fCallback, 'FiltersSave', { 'Raw': raw, 'RawIsActive': boolToAjax(isRawIsActive), - 'Filters': _.map(filters, (item) => item.toJson()) + 'Filters': filters.map(item => item.toJson()) }); } diff --git a/dev/Settings/Admin/Contacts.js b/dev/Settings/Admin/Contacts.js index 16812f1cd..c8a37b48d 100644 --- a/dev/Settings/Admin/Contacts.js +++ b/dev/Settings/Admin/Contacts.js @@ -48,7 +48,7 @@ class ContactsAdminSettings { this.contactsTypes = ko.observableArray([]); this.contactsTypesOptions = ko.computed(() => - _.map(this.contactsTypes(), (value) => { + this.contactsTypes().map(value => { const disabled = supportedTypes.includes(value); return { 'id': value, diff --git a/dev/Settings/Admin/General.js b/dev/Settings/Admin/General.js index f314ecade..6e2b98beb 100644 --- a/dev/Settings/Admin/General.js +++ b/dev/Settings/Admin/General.js @@ -63,7 +63,7 @@ class GeneralAdminSettings { : ''; this.themesOptions = ko.computed(() => - _.map(this.themes(), (theme) => ({ optValue: theme, optText: convertThemeName(theme) })) + this.themes().map(theme => ({ optValue: theme, optText: convertThemeName(theme) })) ); this.languageFullName = ko.computed(() => convertLangName(this.language())); diff --git a/dev/Settings/User/Filters.js b/dev/Settings/User/Filters.js index f633e455c..0d50fcb28 100644 --- a/dev/Settings/User/Filters.js +++ b/dev/Settings/User/Filters.js @@ -114,7 +114,7 @@ class FiltersUserSettings { this.filters( _.compact( - _.map(data.Result.Filters, (aItem) => { + data.Result.Filters.map(aItem => { const filter = new FilterModel(); return filter && filter.parse(aItem) ? filter : null; }) diff --git a/dev/Settings/User/Themes.js b/dev/Settings/User/Themes.js index 698eaa9db..90ca2ebea 100644 --- a/dev/Settings/User/Themes.js +++ b/dev/Settings/User/Themes.js @@ -1,5 +1,4 @@ import window from 'window'; -import _ from '_'; import ko from 'ko'; import Jua from 'Jua'; @@ -63,7 +62,7 @@ class ThemesUserSettings { const currentTheme = this.theme(); this.themesObjects( - _.map(this.themes(), (theme) => ({ + this.themes().map(theme => ({ name: theme, nameDisplay: convertThemeName(theme), selected: ko.observable(theme === currentTheme), diff --git a/dev/Stores/User/Account.js b/dev/Stores/User/Account.js index 732e8238f..d99c0ff1d 100644 --- a/dev/Stores/User/Account.js +++ b/dev/Stores/User/Account.js @@ -17,7 +17,7 @@ class AccountUserStore { } computers() { - this.accountsEmails = ko.computed(() => _.compact(_.map(this.accounts(), (item) => (item ? item.email : null)))); + this.accountsEmails = ko.computed(() => _.compact(this.accounts().map(item => (item ? item.email : null)))); this.accountsUnreadCount = ko.computed(() => 0); // this.accountsUnreadCount = ko.computed(() => { diff --git a/dev/Stores/User/Folder.js b/dev/Stores/User/Folder.js index a797fd77b..7726f7198 100644 --- a/dev/Stores/User/Folder.js +++ b/dev/Stores/User/Folder.js @@ -95,7 +95,7 @@ class FolderUserStore { }); this.folderListSystem = ko.computed(() => - _.compact(_.map(this.folderListSystemNames(), (name) => getFolderFromCacheList(name))) + _.compact(this.folderListSystemNames().map(name => getFolderFromCacheList(name))) ); this.folderMenuForMove = ko.computed(() => diff --git a/dev/Stores/User/Identity.js b/dev/Stores/User/Identity.js index cc80b8573..b8d00df2f 100644 --- a/dev/Stores/User/Identity.js +++ b/dev/Stores/User/Identity.js @@ -6,7 +6,7 @@ class IdentityUserStore { this.identities = ko.observableArray([]); this.identities.loading = ko.observable(false).extend({ throttle: 100 }); - this.identitiesIDS = ko.computed(() => _.compact(_.map(this.identities(), (item) => (item ? item.id : null)))); + this.identitiesIDS = ko.computed(() => _.compact(this.identities().map(item => (item ? item.id : null)))); } } diff --git a/dev/Stores/User/Message.js b/dev/Stores/User/Message.js index 40e921973..53ef0abe7 100644 --- a/dev/Stores/User/Message.js +++ b/dev/Stores/User/Message.js @@ -294,7 +294,7 @@ class MessageUserStore { * @param {boolean=} copy = false */ removeMessagesFromList(fromFolderFullNameRaw, uidForRemove, toFolderFullNameRaw = '', copy = false) { - uidForRemove = _.map(uidForRemove, (mValue) => pInt(mValue)); + uidForRemove = uidForRemove.map(mValue => pInt(mValue)); let unseenCount = 0, messageList = this.messageList(), @@ -709,7 +709,7 @@ class MessageUserStore { * @returns {string} */ calculateMessageListHash(list) { - return _.map(list, (message) => '' + message.hash + '_' + message.threadsLen() + '_' + message.flagHash()).join( + return list.map(message => '' + message.hash + '_' + message.threadsLen() + '_' + message.flagHash()).join( '|' ); } diff --git a/dev/Stores/User/Pgp.js b/dev/Stores/User/Pgp.js index 150e4a6e2..d0a47013e 100644 --- a/dev/Stores/User/Pgp.js +++ b/dev/Stores/User/Pgp.js @@ -44,7 +44,7 @@ class PgpUserStore { findPublicKeysByEmail(email) { return _.compact( _.flatten( - _.map(this.openpgpkeysPublic(), (item) => { + this.openpgpkeysPublic().map(item => { const key = item && item.emails.includes(email) ? item : null; return key ? key.getNativeKeys() : [null]; }), @@ -56,7 +56,7 @@ class PgpUserStore { findPublicKeysBySigningKeyIds(signingKeyIds) { return _.compact( _.flatten( - _.map(signingKeyIds, (id) => { + signingKeyIds.map(id => { const key = id && id.toHex ? this.findPublicKeyByHex(id.toHex()) : null; return key ? key.getNativeKeys() : [null]; }), @@ -69,7 +69,7 @@ class PgpUserStore { let result = isArray(encryptionKeyIds) ? _.compact( _.flatten( - _.map(encryptionKeyIds, (id) => { + encryptionKeyIds.map(id => { const key = id && id.toHex ? this.findPrivateKeyByHex(id.toHex()) : null; return key ? (returnWrapKeys ? [key] : key.getNativeKeys()) : [null]; }), @@ -82,13 +82,13 @@ class PgpUserStore { result = _.uniq( _.compact( _.flatten( - _.map(recipients, (sEmail) => { + recipients.map(sEmail => { const keys = sEmail ? this.findAllPrivateKeysByEmailNotNative(sEmail) : null; return keys ? returnWrapKeys ? keys : _.flatten( - _.map(keys, (key) => key.getNativeKeys()), + keys.map(key => key.getNativeKeys()), true ) : [null]; @@ -297,7 +297,7 @@ class PgpUserStore { } else if (validPrivateKey) { const keyIds = isNonEmptyArray(signingKeyIds) ? signingKeyIds : null, additional = keyIds - ? _.compact(_.map(keyIds, (item) => (item && item.toHex ? item.toHex() : null))).join(', ') + ? _.compact(keyIds.map(item => (item && item.toHex ? item.toHex() : null))).join(', ') : ''; store.controlsHelper( @@ -354,7 +354,7 @@ class PgpUserStore { } else { const keyIds = isNonEmptyArray(signingKeyIds) ? signingKeyIds : null, additional = keyIds - ? _.compact(_.map(keyIds, (item) => (item && item.toHex ? item.toHex() : null))).join(', ') + ? _.compact(keyIds.map(item => (item && item.toHex ? item.toHex() : null))).join(', ') : ''; store.controlsHelper( diff --git a/dev/Stores/User/Template.js b/dev/Stores/User/Template.js index d5791ae00..0959495ce 100644 --- a/dev/Stores/User/Template.js +++ b/dev/Stores/User/Template.js @@ -16,7 +16,7 @@ class TemplateUserStore { subscribers() { this.templates.subscribe((list) => { - this.templatesNames(_.compact(_.map(list, (item) => (item ? item.name : null)))); + this.templatesNames(_.compact(list.map(item => (item ? item.name : null)))); }); // this.templatesNames.subscribe((aList) => { diff --git a/dev/View/Popup/Compose.js b/dev/View/Popup/Compose.js index 5acfb2a46..22bb94b90 100644 --- a/dev/View/Popup/Compose.js +++ b/dev/View/Popup/Compose.js @@ -257,7 +257,7 @@ class ComposePopupView extends AbstractViewNext { this.identities = IdentityStore.identities; this.identitiesOptions = ko.computed(() => - _.map(IdentityStore.identities(), (item) => ({ + IdentityStore.identities().map(item => ({ 'item': item, 'optValue': item.id(), 'optText': item.formattedName() @@ -541,7 +541,7 @@ class ComposePopupView extends AbstractViewNext { emailsSource(oData, fResponse) { getApp().getAutocomplete(oData.term, (aData) => { - fResponse(_.map(aData, (oEmailItem) => oEmailItem.toLine(false))); + fResponse(aData.map(oEmailItem => oEmailItem.toLine(false))); }); } @@ -859,7 +859,7 @@ class ComposePopupView extends AbstractViewNext { addEmailsTo(fKoValue, emails) { if (isNonEmptyArray(emails)) { const value = trim(fKoValue()), - values = _.uniq(_.compact(_.map(emails, (item) => (item ? item.toLine(false) : null)))); + values = _.uniq(_.compact(emails.map(item => (item ? item.toLine(false) : null)))); fKoValue(value + ('' === value ? '' : ', ') + trim(values.join(', '))); } @@ -873,7 +873,7 @@ class ComposePopupView extends AbstractViewNext { */ emailArrayToStringLineHelper(aList, bFriendly) { bFriendly = !!bFriendly; - return _.map(aList, (item) => item.toLine(bFriendly)).join(', '); + return aList.map(item => item.toLine(bFriendly)).join(', '); } /** @@ -1605,9 +1605,8 @@ class ComposePopupView extends AbstractViewNext { * @returns {Array} */ getAttachmentsDownloadsForUpload() { - return _.map( - this.attachments().filter(item => item && '' === item.tempName()), - (item) => item.id + return this.attachments().filter(item => item && '' === item.tempName()).map( + item => item.id ); } diff --git a/dev/View/Popup/ComposeOpenPgp.js b/dev/View/Popup/ComposeOpenPgp.js index b9083670a..a9e42b791 100644 --- a/dev/View/Popup/ComposeOpenPgp.js +++ b/dev/View/Popup/ComposeOpenPgp.js @@ -44,14 +44,14 @@ class ComposeOpenPgpPopupView extends AbstractViewNext { this.signKey = ko.observable(null); this.encryptKeys = ko.observableArray([]); - this.encryptKeysView = ko.computed(() => _.compact(_.map(this.encryptKeys(), (oKey) => (oKey ? oKey.key : null)))); + this.encryptKeysView = ko.computed(() => _.compact(this.encryptKeys().map(oKey => (oKey ? oKey.key : null)))); this.privateKeysOptions = ko.computed(() => { - const opts = _.map(PgpStore.openpgpkeysPrivate(), (oKey, iIndex) => { + const opts = PgpStore.openpgpkeysPrivate().map((oKey, iIndex) => { if (this.signKey() && this.signKey().key.id === oKey.id) { return null; } - return _.map(oKey.users, (user) => ({ + return oKey.users.map(user => ({ 'id': oKey.guid, 'name': '(' + oKey.id.substr(KEY_NAME_SUBSTR).toUpperCase() + ') ' + user, 'key': oKey, @@ -63,11 +63,11 @@ class ComposeOpenPgpPopupView extends AbstractViewNext { }); this.publicKeysOptions = ko.computed(() => { - const opts = _.map(PgpStore.openpgpkeysPublic(), (oKey, index) => { + const opts = PgpStore.openpgpkeysPublic().map((oKey, index) => { if (this.encryptKeysView().includes(oKey)) { return null; } - return _.map(oKey.users, (user) => ({ + return oKey.users.map(user => ({ 'id': oKey.guid, 'name': '(' + oKey.id.substr(KEY_NAME_SUBSTR).toUpperCase() + ') ' + user, 'key': oKey, @@ -356,7 +356,7 @@ class ComposeOpenPgpPopupView extends AbstractViewNext { rec = rec.join(', ').split(','); rec = _.compact( - _.map(rec, (value) => { + rec.map(value => { email.clear(); email.parse(trim(value)); return '' === email.email ? false : email.email; @@ -386,10 +386,10 @@ class ComposeOpenPgpPopupView extends AbstractViewNext { _.uniq( _.compact( _.flatten( - _.map(rec, (recEmail) => { + rec.map(recEmail => { const keys = PgpStore.findAllPublicKeysByEmailNotNative(recEmail); return keys - ? _.map(keys, (publicKey) => ({ + ? keys.map(publicKey => ({ 'empty': !publicKey, 'selected': ko.observable(!!publicKey), 'removable': ko.observable( diff --git a/dev/View/Popup/Contacts.js b/dev/View/Popup/Contacts.js index d50a003fe..f7be9ac81 100644 --- a/dev/View/Popup/Contacts.js +++ b/dev/View/Popup/Contacts.js @@ -175,7 +175,7 @@ class ContactsPopupView extends AbstractViewNext { }); this.contactsCheckedOrSelectedUids = ko.computed(() => - _.map(this.contactsCheckedOrSelected(), (contact) => contact.idContact) + this.contactsCheckedOrSelected().map(contact => contact.idContact) ); this.selector = new Selector( @@ -202,7 +202,7 @@ class ContactsPopupView extends AbstractViewNext { this.watchDirty = ko.observable(false); this.watchHash = ko.observable(false); - this.viewHash = ko.computed(() => '' + _.map(this.viewProperties(), (oItem) => oItem.value()).join('')); + this.viewHash = ko.computed(() => '' + this.viewProperties().map(oItem => oItem.value()).join('')); // this.saveCommandDebounce = _.debounce(this.saveCommand.bind(this), 1000); @@ -240,7 +240,7 @@ class ContactsPopupView extends AbstractViewNext { const aC = this.contactsCheckedOrSelected(); if (isNonEmptyArray(aC)) { - aE = _.map(aC, (oItem) => { + aE = aC.map(oItem => { if (oItem) { const data = oItem.getNameAndEmailHelper(), email = data ? new EmailModel(data[0], data[1]) : null; @@ -591,7 +591,7 @@ class ContactsPopupView extends AbstractViewNext { if (StorageResultType.Success === result && data && data.Result && data.Result.List) { if (isNonEmptyArray(data.Result.List)) { - list = _.map(data.Result.List, (item) => { + list = data.Result.List.map(item => { const contact = new ContactModel(); return contact.parse(item) ? contact : null; }); diff --git a/dev/View/Popup/DomainAlias.js b/dev/View/Popup/DomainAlias.js index ed4c3e1a4..70b8b7fca 100644 --- a/dev/View/Popup/DomainAlias.js +++ b/dev/View/Popup/DomainAlias.js @@ -1,4 +1,3 @@ -import _ from '_'; import ko from 'ko'; import { StorageResultType, Notification } from 'Common/Enums'; @@ -33,7 +32,7 @@ class DomainAliasPopupView extends AbstractViewNext { this.domains = DomainStore.domainsWithoutAliases; this.domainsOptions = ko.computed(() => - _.map(this.domains(), (item) => ({ optValue: item.name, optText: item.name })) + this.domains().map(item => ({ optValue: item.name, optText: item.name })) ); this.canBeSaved = ko.computed(() => !this.saving() && '' !== this.name() && '' !== this.alias()); diff --git a/dev/View/Popup/Languages.js b/dev/View/Popup/Languages.js index e9f5a3a50..6f2c8dec5 100644 --- a/dev/View/Popup/Languages.js +++ b/dev/View/Popup/Languages.js @@ -1,4 +1,3 @@ -import _ from '_'; import ko from 'ko'; import { convertLangName } from 'Common/Utils'; @@ -22,7 +21,7 @@ class LanguagesPopupView extends AbstractViewNext { this.languages = ko.computed(() => { const userLanguage = this.userLanguage(); - return _.map(this.langs(), (language) => ({ + return this.langs().map(language => ({ key: language, user: language === userLanguage, selected: ko.observable(false), diff --git a/dev/View/Popup/Plugin.js b/dev/View/Popup/Plugin.js index c4c1c7923..3cdfaab7f 100644 --- a/dev/View/Popup/Plugin.js +++ b/dev/View/Popup/Plugin.js @@ -88,7 +88,7 @@ class PluginPopupView extends AbstractViewNext { const config = oPlugin.Config; if (isNonEmptyArray(config)) { this.configures( - _.map(config, (item) => ({ + config.map(item => ({ 'value': ko.observable(item[0]), 'placeholder': ko.observable(item[6]), 'Name': item[1], diff --git a/dev/View/User/MailBox/MessageList.js b/dev/View/User/MailBox/MessageList.js index 17b07dfbf..e6c44aa06 100644 --- a/dev/View/User/MailBox/MessageList.js +++ b/dev/View/User/MailBox/MessageList.js @@ -651,7 +651,7 @@ class MessageListMailBoxUserView extends AbstractViewNext { flagMessages(currentMessage) { const checked = this.messageListCheckedOrSelected(); if (currentMessage) { - const checkedUids = _.map(checked, (message) => message.uid); + const checkedUids = checked.map(message => message.uid); if (0 < checkedUids.length && checkedUids.includes(currentMessage.uid)) { this.setAction( currentMessage.folderFullNameRaw, diff --git a/dev/View/User/MailBox/MessageView.js b/dev/View/User/MailBox/MessageView.js index 3166fd78f..ee98cf840 100644 --- a/dev/View/User/MailBox/MessageView.js +++ b/dev/View/User/MailBox/MessageView.js @@ -453,7 +453,7 @@ class MessageViewMailBoxUserView extends AbstractViewNext { // aTo = [], // EmailModel = require('Model/Email').default, // fParseEmailLine = function(sLine) { - // return sLine ? _.compact(_.map([window.decodeURIComponent(sLine)], function(sItem) { + // return sLine ? _.compact([window.decodeURIComponent(sLine)].map(sItem => { // var oEmailModel = new EmailModel(); // oEmailModel.parse(sItem); // return '' !== oEmailModel.email ? oEmailModel : null; @@ -478,7 +478,7 @@ class MessageViewMailBoxUserView extends AbstractViewNext { const div = $('
'), dynamicEls = _.compact( - _.map(this.message().attachments(), (item) => { + this.message().attachments().map(item => { if (item && !item.isLinked && item.isImage()) { if (item === attachment) { index = listIndex; @@ -885,7 +885,7 @@ class MessageViewMailBoxUserView extends AbstractViewNext { getAttachmentsHashes() { const atts = this.message() ? this.message().attachments() : []; - return _.compact(_.map(atts, (item) => (item && !item.isLinked && item.checked() ? item.download : ''))); + return _.compact(atts.map(item => (item && !item.isLinked && item.checked() ? item.download : ''))); } downloadAsZip() {