Object.entries().forEach() to forEachObjectEntry()

This commit is contained in:
djmaze 2021-12-01 14:23:37 +01:00
parent b8eb8f83fa
commit 6d7911a9ed
8 changed files with 18 additions and 18 deletions

View file

@ -2,7 +2,7 @@ import ko from 'ko';
import { Notification, UploadErrorCode } from 'Common/Enums';
import { langLink } from 'Common/Links';
import { doc, createElement } from 'Common/Globals';
import { getKeyByValue } from 'Common/Utils';
import { getKeyByValue, forEachObjectEntry } from 'Common/Utils';
let I18N_DATA = {};
@ -66,7 +66,7 @@ export const
}
}
if (valueList) {
Object.entries(valueList).forEach(([key, value]) => {
forEachObjectEntry(valueList, (key, value) => {
result = result.replace('%' + key + '%', value);
});
}

View file

@ -1,4 +1,4 @@
import { isArray, isFunction, addObservablesTo, addComputablesTo, forEachObjectValue } from 'Common/Utils';
import { isArray, isFunction, addObservablesTo, addComputablesTo, forEachObjectValue, forEachObjectEntry } from 'Common/Utils';
function dispose(disposable) {
if (disposable && isFunction(disposable.dispose)) {
@ -43,7 +43,7 @@ export class AbstractModel {
}
addSubscribables(subscribables) {
Object.entries(subscribables).forEach(([key, fn]) => this.subscribables.push( this[key].subscribe(fn) ) );
forEachObjectEntry(subscribables, (key, fn) => this.subscribables.push( this[key].subscribe(fn) ) );
}
/** Called by delegateRunOnDestroy */
@ -51,7 +51,7 @@ export class AbstractModel {
/** dispose ko subscribables */
this.subscribables.forEach(dispose);
/** clear object entries */
// Object.entries(this).forEach(([key, value]) => {
// forEachObjectEntry(this, (key, value) => {
forEachObjectValue(this, value => {
/** clear CollectionModel */
let arr = ko.isObservableArray(value) ? value() : value;
@ -89,7 +89,7 @@ export class AbstractModel {
if (!model.validJson(json)) {
return false;
}
Object.entries(json).forEach(([key, value]) => {
forEachObjectEntry(json, (key, value) => {
if ('@' !== key[0]) try {
key = key[0].toLowerCase() + key.substr(1);
switch (typeof this[key])

View file

@ -1,7 +1,7 @@
import ko from 'ko';
import { doc, $htmlCL, elementById } from 'Common/Globals';
import { isFunction, forEachObjectValue } from 'Common/Utils';
import { isFunction, forEachObjectValue, forEachObjectEntry } from 'Common/Utils';
let
SCREENS = {},
@ -349,7 +349,7 @@ export const
},
decorateKoCommands = (thisArg, commands) =>
Object.entries(commands).forEach(([key, canExecute]) => {
forEachObjectEntry(commands, (key, canExecute) => {
let command = thisArg[key],
fn = (...args) => fn.enabled() && fn.canExecute() && command.apply(thisArg, args);

View file

@ -1,4 +1,4 @@
import { isArray } from 'Common/Utils';
import { isArray, forEachObjectEntry } from 'Common/Utils';
export class AbstractCollectionModel extends Array
{
@ -24,7 +24,7 @@ export class AbstractCollectionModel extends Array
const result = new this();
if (json) {
if ('Collection/'+this.name.replace('Model', '') === json['@Object']) {
Object.entries(json).forEach(([key, value]) => '@' !== key[0] && (result[key] = value));
forEachObjectEntry(json, (key, value) => '@' !== key[0] && (result[key] = value));
json = json['@Collection'];
}
if (isArray(json)) {

View file

@ -4,7 +4,7 @@ import { MessagePriority } from 'Common/EnumsUser';
import { i18n } from 'Common/Translator';
import { encodeHtml } from 'Common/Html';
import { isArray, arrayLength } from 'Common/Utils';
import { isArray, arrayLength, forEachObjectEntry } from 'Common/Utils';
import { serverRequestRaw } from 'Common/Links';
@ -275,7 +275,7 @@ export class MessageModel extends AbstractModel {
*/
lineAsCss() {
let classes = [];
Object.entries({
forEachObjectEntry({
deleted: this.deleted(),
'deleted-mark': this.isDeleted(),
selected: this.selected(),
@ -291,7 +291,7 @@ export class MessageModel extends AbstractModel {
// hasChildrenMessage: 1 < this.threadsLen(),
hasUnseenSubMessage: this.hasUnseenSubMessage(),
hasFlaggedSubMessage: this.hasFlaggedSubMessage()
}).forEach(([key, value]) => value && classes.push(key));
}, (key, value) => value && classes.push(key));
return classes.join(' ');
}

View file

@ -12,7 +12,7 @@ import {
SetSystemFoldersNotification
} from 'Common/EnumsUser';
import { inFocus, pInt, isArray, arrayLength } from 'Common/Utils';
import { inFocus, pInt, isArray, arrayLength, forEachObjectEntry } from 'Common/Utils';
import { delegateRunOnDestroy, initFullscreen } from 'Common/UtilsUser';
import { encodeHtml, HtmlEditor } from 'Common/Html';
@ -1018,7 +1018,7 @@ class ComposePopupView extends AbstractViewPopup {
if (arrayLength(downloads)) {
Remote.messageUploadAttachments((iError, oData) => {
if (!iError) {
Object.entries(oData.Result).forEach(([tempName, id]) => {
forEachObjectEntry(oData.Result, (tempName, id) => {
const attachment = this.getAttachmentById(id);
if (attachment) {
attachment.tempName(tempName);

View file

@ -1,4 +1,4 @@
import { pInt, pString } from 'Common/Utils';
import { pInt, pString, forEachObjectEntry } from 'Common/Utils';
import { i18n, getNotification } from 'Common/Translator';
import Remote from 'Remote/Admin/Fetch';
@ -275,7 +275,7 @@ class DomainPopupView extends AbstractViewPopup {
clearForm() {
this.edit(false);
Object.entries(this.getDefaults()).forEach(([key, value]) => this[key](value));
forEachObjectEntry(this.getDefaults(), (key, value) => this[key](value));
this.enableSmartPorts(true);
}
}

View file

@ -63,7 +63,7 @@ export class SystemDropDownUserView extends AbstractViewRight {
}
} else {
/* // Not working yet
Object.entries(oData.Result).forEach((key, value) => rl.settings.set(key, value));
forEachObjectEntry(oData.Result, (key, value) => rl.settings.set(key, value));
clearCache();
// MessageUserStore.setMessage();
// MessageUserStore.purgeMessageBodyCache();