JavaScript inArray()/indexOf() to .includes()

This commit is contained in:
djmaze 2020-07-20 14:33:33 +02:00
parent ec3fd5b7e4
commit db2d95d684
20 changed files with 69 additions and 86 deletions

View file

@ -3,7 +3,7 @@ import _ from '_';
import key from 'key';
import ko from 'ko';
import { EventKeyCode } from 'Common/Enums';
import { isArray, inArray, noop, noopTrue } from 'Common/Utils';
import { isArray, noop, noopTrue } from 'Common/Utils';
class Selector {
list;
@ -159,7 +159,7 @@ class Selector {
mFocused = null;
}
if (0 < len && -1 < inArray(uid, aCheckedCache)) {
if (0 < len && aCheckedCache.includes(uid)) {
isChecked = true;
item.checked(true);
len -= 1;
@ -181,7 +181,7 @@ class Selector {
if (null !== isNextFocused) {
getNext = false;
isNextFocused = _.find(aCache, (sUid) => {
if (getNext && -1 < inArray(sUid, uids)) {
if (getNext && uids.includes(sUid)) {
return sUid;
} else if (isNextFocused === sUid) {
getNext = true;

View file

@ -3,7 +3,7 @@ import _ from '_';
import $ from '$';
import ko from 'ko';
import { Notification, UploadErrorCode } from 'Common/Enums';
import { pInt, isUnd, isNull, has, microtime, inArray } from 'Common/Utils';
import { pInt, isUnd, isNull, has, microtime } from 'Common/Utils';
import { $html, $htmlCL } from 'Common/Globals';
import { reload as momentorReload } from 'Common/Momentor';
import { langLink } from 'Common/Links';
@ -274,7 +274,7 @@ export function reload(admin, language) {
() => {
reloadData();
const isRtl = -1 < inArray((language || '').toLowerCase(), ['ar', 'ar_sa', 'he', 'he_he', 'ur', 'ur_ir']);
const isRtl = ['ar', 'ar_sa', 'he', 'he_he', 'ur', 'ur_ir'].includes((language || '').toLowerCase());
$htmlCL.remove('rl-changing-language', 'rl-rtl', 'rl-ltr');
// $html.attr('dir', isRtl ? 'rtl' : 'ltr')

View file

@ -10,8 +10,7 @@ import { Mime } from 'Common/Mime';
import { jassl } from 'Common/Jassl';
const trim = $.trim;
const inArray = $.inArray;
const isArray = _.isArray;
const isArray = Array.isArray;
const isObject = _.isObject;
const isFunc = _.isFunction;
const isUnd = _.isUndefined;
@ -22,7 +21,7 @@ const noop = () => {}; // eslint-disable-line no-empty-function
const noopTrue = () => true;
const noopFalse = () => false;
export { trim, inArray, isArray, isObject, isFunc, isUnd, isNull, has, bind, noop, noopTrue, noopFalse, jassl };
export { trim, isArray, isObject, isFunc, isUnd, isNull, has, bind, noop, noopTrue, noopFalse, jassl };
/**
* @param {Function} func
@ -935,7 +934,7 @@ export function folderListOptionsBuilder(
seporator: false,
disabled:
!oItem.selectable ||
-1 < inArray(oItem.fullNameRaw, aDisabled) ||
aDisabled.includes(oItem.fullNameRaw) ||
(fDisableCallback ? fDisableCallback(oItem) : false)
});
}
@ -971,7 +970,7 @@ export function folderListOptionsBuilder(
seporator: false,
disabled:
!oItem.selectable ||
-1 < inArray(oItem.fullNameRaw, aDisabled) ||
aDisabled.includes(oItem.fullNameRaw) ||
(fDisableCallback ? fDisableCallback(oItem) : false)
});
}