-1…*.indexOf() to native .includes()

This commit is contained in:
djmaze 2020-07-20 21:39:00 +02:00
parent eb15c6e45f
commit 961fa305c9
8 changed files with 19 additions and 19 deletions

View file

@ -49,17 +49,17 @@ export const sUserAgent =
/**
* @type {boolean}
*/
export const bIE = -1 < sUserAgent.indexOf('msie');
export const bIE = sUserAgent.includes('msie');
/**
* @type {boolean}
*/
export const bChrome = -1 < sUserAgent.indexOf('chrome');
export const bChrome = sUserAgent.includes('chrome');
/**
* @type {boolean}
*/
export const bSafari = !bChrome && -1 < sUserAgent.indexOf('safari');
export const bSafari = !bChrome && sUserAgent.includes('safari');
/**
* @type {boolean}

2
dev/External/ko.js vendored
View file

@ -818,7 +818,7 @@ ko.bindingHandlers.emailsTags = {
autoCompleteSource: fAutoCompleteSource,
splitHook: (value) => {
const v = Utils.trim(value);
if (v && -1 < inputDelimiters.indexOf(v.substr(-1))) {
if (v && inputDelimiters.includes(v.substr(-1))) {
return EmailModel.splitEmailLine(value);
}
return null;

View file

@ -73,7 +73,7 @@ class EmailModel {
* @returns {boolean}
*/
search(query) {
return -1 < (this.name + ' ' + this.email).toLowerCase().indexOf(query.toLowerCase());
return (this.name + ' ' + this.email).toLowerCase().includes(query.toLowerCase());
}
/**

View file

@ -23,7 +23,7 @@ class PromisesUserPopulator extends AbstractBasicPromises {
* @returns {boolean}
*/
isFolderExpanded(sFullNameHash, expandedFolders) {
return expandedFolders && isArray(expandedFolders) && -1 !== _.indexOf(expandedFolders, sFullNameHash);
return expandedFolders && isArray(expandedFolders) && expandedFolders.includes(sFullNameHash);
}
/**

View file

@ -315,7 +315,7 @@ class RemoteUserAjax extends AbstractAjaxRemote {
useThreads = AppStore.threadsAllowed() && SettingsStore.useThreads(),
inboxUidNext = getFolderInboxName() === sFolderFullNameRaw ? getFolderUidNext(sFolderFullNameRaw) : '';
if ('' !== folderHash && ('' === sSearch || -1 === sSearch.indexOf('is:'))) {
if ('' !== folderHash && ('' === sSearch || !sSearch.includes('is:'))) {
return this.defaultRequest(
fCallback,
'MessageList',

View file

@ -30,7 +30,7 @@ class PgpUserStore {
}
findKeyByHex(keys, hash) {
return _.find(keys, (item) => hash && item && (hash === item.id || -1 < item.ids.indexOf(hash)));
return _.find(keys, (item) => hash && item && (hash === item.id || item.ids.includes(hash)));
}
findPublicKeyByHex(hash) {
@ -45,7 +45,7 @@ class PgpUserStore {
return _.compact(
_.flatten(
_.map(this.openpgpkeysPublic(), (item) => {
const key = item && -1 < item.emails.indexOf(email) ? item : null;
const key = item && item.emails.includes(email) ? item : null;
return key ? key.getNativeKeys() : [null];
}),
true
@ -108,7 +108,7 @@ class PgpUserStore {
* @returns {?}
*/
findPublicKeyByEmailNotNative(email) {
return _.find(this.openpgpkeysPublic(), (item) => item && -1 < item.emails.indexOf(email)) || null;
return _.find(this.openpgpkeysPublic(), (item) => item && item.emails.includes(email)) || null;
}
/**
@ -116,7 +116,7 @@ class PgpUserStore {
* @returns {?}
*/
findPrivateKeyByEmailNotNative(email) {
return _.find(this.openpgpkeysPrivate(), (item) => item && -1 < item.emails.indexOf(email)) || null;
return _.find(this.openpgpkeysPrivate(), (item) => item && item.emails.includes(email)) || null;
}
/**
@ -124,7 +124,7 @@ class PgpUserStore {
* @returns {?}
*/
findAllPublicKeysByEmailNotNative(email) {
return this.openpgpkeysPublic().filter(item => item && -1 < item.emails.indexOf(email)) || null;
return this.openpgpkeysPublic().filter(item => item && item.emails.includes(email)) || null;
}
/**
@ -132,7 +132,7 @@ class PgpUserStore {
* @returns {?}
*/
findAllPrivateKeysByEmailNotNative(email) {
return this.openpgpkeysPrivate().filter(item => item && -1 < item.emails.indexOf(email)) || null;
return this.openpgpkeysPrivate().filter(item => item && item.emails.includes(email)) || null;
}
/**
@ -142,7 +142,7 @@ class PgpUserStore {
*/
findPrivateKeyByEmail(email, password) {
let privateKey = null;
const key = _.find(this.openpgpkeysPrivate(), (item) => item && -1 < item.emails.indexOf(email));
const key = _.find(this.openpgpkeysPrivate(), (item) => item && item.emails.includes(email));
if (key) {
try {

View file

@ -73,7 +73,7 @@ class AdvancedSearchPopupView extends AbstractViewNext {
}
buildSearchStringValue(value) {
if (-1 < value.indexOf(' ')) {
if (value.includes(' ')) {
value = '"' + value + '"';
}
return value;

View file

@ -739,7 +739,7 @@ class ComposePopupView extends AbstractViewNext {
if ('' !== fromLine) {
signature = signature.replace(/{{FROM-FULL}}/g, fromLine);
if (-1 === fromLine.indexOf(' ') && 0 < fromLine.indexOf('@')) {
if (!fromLine.includes(' ') && 0 < fromLine.indexOf('@')) {
fromLine = fromLine.replace(/@[\S]+/, '');
}
@ -752,14 +752,14 @@ class ComposePopupView extends AbstractViewNext {
signature = signature.replace(/{{FROM}}/g, '');
signature = signature.replace(/{{FROM-FULL}}/g, '');
if (-1 < signature.indexOf('{{DATE}}')) {
if (signature.includes('{{DATE}}')) {
signature = signature.replace(/{{DATE}}/g, momentorFormat(0, 'llll'));
}
if (-1 < signature.indexOf('{{TIME}}')) {
if (signature.includes('{{TIME}}')) {
signature = signature.replace(/{{TIME}}/g, momentorFormat(0, 'LT'));
}
if (-1 < signature.indexOf('{{MOMENT:')) {
if (signature.includes('{{MOMENT:')) {
try {
let match = null;
while (null !== (match = momentRegx.exec(signature))) {