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

@ -146,7 +146,7 @@ class FilterModel extends AbstractModel {
}
if (0 < this.conditions().length) {
if (_.find(this.conditions(), (cond) => cond && !cond.verify())) {
if (this.conditions().find(cond => cond && !cond.verify())) {
return false;
}
}

View file

@ -1,4 +1,3 @@
import _ from '_';
import ko from 'ko';
import { FolderType } from 'Common/Enums';
@ -64,9 +63,8 @@ class FolderModel extends AbstractModel {
this.hasSubScribedSubfolders = ko.computed(
() =>
!!_.find(
this.subFolders(),
(oFolder) => (oFolder.subScribed() || oFolder.hasSubScribedSubfolders()) && !oFolder.isSystemFolder()
!!this.subFolders().find(
oFolder => (oFolder.subScribed() || oFolder.hasSubScribedSubfolders()) && !oFolder.isSystemFolder()
)
);
@ -230,9 +228,8 @@ class FolderModel extends AbstractModel {
this.hasSubScribedUnreadMessagesSubfolders = ko.computed(
() =>
!!_.find(
this.subFolders(),
(folder) => folder.hasUnreadMessages() || folder.hasSubScribedUnreadMessagesSubfolders()
!!this.subFolders().find(
folder => folder.hasUnreadMessages() || folder.hasSubScribedUnreadMessagesSubfolders()
)
);

View file

@ -493,7 +493,7 @@ class MessageModel extends AbstractModel {
* @returns {boolean}
*/
hasVisibleAttachments() {
return !!_.find(this.attachments(), (item) => !item.isLinked);
return !!this.attachments().find(item => !item.isLinked);
}
/**
@ -506,7 +506,7 @@ class MessageModel extends AbstractModel {
if (isNonEmptyArray(attachments)) {
cid = cid.replace(/^<+/, '').replace(/>+$/, '');
result = _.find(attachments, (item) => cid === item.cidWithOutTags);
result = attachments.find(item => cid === item.cidWithOutTags);
}
return result || null;
@ -521,7 +521,7 @@ class MessageModel extends AbstractModel {
const attachments = this.attachments();
if (isNonEmptyArray(attachments)) {
result = _.find(attachments, (item) => contentLocation === item.contentLocation);
result = attachments.find(item => contentLocation === item.contentLocation);
}
return result || null;