Underscore.js _.find() to native Array.find()

This commit is contained in:
djmaze 2020-07-22 10:43:19 +02:00
parent 2404f6466d
commit 9c0072d626
19 changed files with 55 additions and 79 deletions

View file

@ -1263,12 +1263,12 @@ class ComposePopupView extends AbstractViewNext {
* @returns {?Object}
*/
getAttachmentById(id) {
return _.find(this.attachments(), (item) => item && id === item.id);
return this.attachments().find(item => item && id === item.id);
}
cancelAttachmentHelper(id, oJua) {
return () => {
const attachment = _.find(this.attachments(), (item) => item && item.id === id);
const attachment = this.attachments().find(item => item && item.id === id);
if (attachment) {
this.attachments.remove(attachment);
delegateRunOnDestroy(attachment);
@ -1516,7 +1516,7 @@ class ComposePopupView extends AbstractViewNext {
}
removeLinkedAttachments() {
const arrachment = _.find(this.attachments(), (item) => item && item.isLinked);
const arrachment = this.attachments().find(item => item && item.isLinked);
if (arrachment) {
this.attachments.remove(arrachment);
delegateRunOnDestroy(arrachment);

View file

@ -244,7 +244,7 @@ class ComposeOpenPgpPopupView extends AbstractViewNext {
@command()
selectCommand() {
const keyId = this.selectedPrivateKey(),
option = keyId ? _.find(this.privateKeysOptions(), (item) => item && keyId === item.id) : null;
option = keyId ? this.privateKeysOptions().find(item => item && keyId === item.id) : null;
if (option) {
this.signKey({
@ -261,7 +261,7 @@ class ComposeOpenPgpPopupView extends AbstractViewNext {
addCommand() {
const keyId = this.selectedPublicKey(),
keys = this.encryptKeys(),
option = keyId ? _.find(this.publicKeysOptions(), (item) => item && keyId === item.id) : null;
option = keyId ? this.publicKeysOptions().find(item => item && keyId === item.id) : null;
if (option) {
keys.push({

View file

@ -119,7 +119,7 @@ class ContactsPopupView extends AbstractViewNext {
emails = this.viewPropertiesEmails(),
fFilter = (property) => '' !== trim(property.value());
return !!(_.find(names, fFilter) || _.find(emails, fFilter));
return !!(names.find(fFilter) || emails.find(fFilter));
});
this.viewPropertiesPhones = ko.computed(() =>
@ -381,7 +381,7 @@ class ContactsPopupView extends AbstractViewNext {
}
addNewOrFocusProperty(type, typeStr) {
const item = _.find(this.viewProperties(), (prop) => type === prop.type());
const item = this.viewProperties().find(prop => type === prop.type());
if (item) {
item.focused(true);
} else {

View file

@ -255,9 +255,8 @@ class MessageListMailBoxUserView extends AbstractViewNext {
});
Events.sub('mailbox.message.show', (sFolder, sUid) => {
const message = _.find(
this.messageList(),
(item) => item && sFolder === item.folderFullNameRaw && sUid === item.uid
const message = this.messageList().find(
item => item && sFolder === item.folderFullNameRaw && sUid === item.uid
);
if ('INBOX' === sFolder) {
@ -411,7 +410,7 @@ class MessageListMailBoxUserView extends AbstractViewNext {
temp = null,
current = null;
_.find(this.messageListPagenator(), (item) => {
this.messageListPagenator().find(item => {
if (item) {
if (current) {
next = item;
@ -942,9 +941,8 @@ class MessageListMailBoxUserView extends AbstractViewNext {
prefetchNextTick() {
if (ifvisible && !this.bPrefetch && !ifvisible.now() && this.viewModelVisibility()) {
const message = _.find(
this.messageList(),
(item) => item && !hasRequestedMessage(item.folderFullNameRaw, item.uid)
const message = this.messageList().find(
item => item && !hasRequestedMessage(item.folderFullNameRaw, item.uid)
);
if (message) {
this.bPrefetch = true;