Array.isArray to isArray

Array.isNotEmpty to isNonEmptyArray
This commit is contained in:
djmaze 2021-03-16 16:49:14 +01:00
parent 986b8f056b
commit 0b64083543
30 changed files with 82 additions and 69 deletions

View file

@ -1,5 +1,5 @@
import { MessageSetAction } from 'Common/EnumsUser';
import { pInt } from 'Common/Utils';
import { isNonEmptyArray, pInt } from 'Common/Utils';
let FOLDERS_CACHE = {},
FOLDERS_NAME_CACHE = {},
@ -255,7 +255,7 @@ export class MessageFlagsCache
* @param {Array} flags
*/
static storeByFolderAndUid(folder, uid, flags) {
if (Array.isNotEmpty(flags)) {
if (isNonEmptyArray(flags)) {
this.setFor(folder, uid, flags);
}
}
@ -269,7 +269,7 @@ export class MessageFlagsCache
let unread = 0;
const flags = this.getFor(folder, uid);
if (Array.isNotEmpty(flags)) {
if (isNonEmptyArray(flags)) {
if (flags[0]) {
unread = 1;
}

View file

@ -1,6 +1,8 @@
/* eslint key-spacing: 0 */
/* eslint quote-props: 0 */
import { isNonEmptyArray } from 'Common/Utils';
const
cache = {},
app = 'application/',
@ -279,7 +281,7 @@ export const FileInfo = {
* @returns {string}
*/
getCombinedIconClass: data => {
if (Array.isNotEmpty(data)) {
if (isNonEmptyArray(data)) {
let icons = data
.map(item => item ? FileInfo.getIconClass(FileInfo.getExtension(item[0]), item[1])[0] : '')
.validUnique();

View file

@ -1,4 +1,5 @@
import ko from 'ko';
import { isArray } from 'Common/Utils';
export class Selector {
/**
@ -79,7 +80,7 @@ export class Selector {
this.list.subscribe(
items => {
if (Array.isArray(items)) {
if (isArray(items)) {
items.forEach(item => {
if (item) {
const uid = this.getItemUid(item);
@ -115,7 +116,7 @@ export class Selector {
this.focusedItem(null);
this.selectedItem(null);
if (Array.isArray(aItems)) {
if (isArray(aItems)) {
len = aCheckedCache.length;
aItems.forEach(item => {

View file

@ -3,7 +3,7 @@ import { doc, elementById } from 'Common/Globals';
export const
isArray = Array.isArray,
isNonEmptyArray = Array.isNotEmpty;
isNonEmptyArray = array => isArray(array) && array.length;
/**
* @param {*} value
@ -116,7 +116,7 @@ export function changeTheme(value, themeTrigger = ()=>{}) {
}
rl.fetchJSON(url, init)
.then(data => {
if (data && Array.isArray(data) && 2 === data.length) {
if (data && isArray(data) && 2 === data.length) {
if (themeLink && !themeStyle) {
themeStyle = doc.createElement('style');
themeStyle.id = 'app-theme-style';
@ -139,7 +139,7 @@ export function changeTheme(value, themeTrigger = ()=>{}) {
export function addObservablesTo(target, observables) {
Object.entries(observables).forEach(([key, value]) =>
target[key] = /*Array.isArray(value) ? ko.observableArray(value) :*/ ko.observable(value) );
target[key] = /*isArray(value) ? ko.observableArray(value) :*/ ko.observable(value) );
}
export function addComputablesTo(target, computables) {