diff --git a/dev/Common/Translator.js b/dev/Common/Translator.js index 2c21f2391..6b5eeb2ff 100644 --- a/dev/Common/Translator.js +++ b/dev/Common/Translator.js @@ -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); }); } diff --git a/dev/Knoin/AbstractModel.js b/dev/Knoin/AbstractModel.js index 853af82e4..6bc95edf6 100644 --- a/dev/Knoin/AbstractModel.js +++ b/dev/Knoin/AbstractModel.js @@ -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]) diff --git a/dev/Knoin/Knoin.js b/dev/Knoin/Knoin.js index 8a194a4a8..e254b43b2 100644 --- a/dev/Knoin/Knoin.js +++ b/dev/Knoin/Knoin.js @@ -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); diff --git a/dev/Model/AbstractCollection.js b/dev/Model/AbstractCollection.js index 375c3a070..85dd57449 100644 --- a/dev/Model/AbstractCollection.js +++ b/dev/Model/AbstractCollection.js @@ -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)) { diff --git a/dev/Model/Message.js b/dev/Model/Message.js index 0315aec96..3f6997886 100644 --- a/dev/Model/Message.js +++ b/dev/Model/Message.js @@ -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(' '); } diff --git a/dev/View/Popup/Compose.js b/dev/View/Popup/Compose.js index 1ba0f3ce1..ebd04ee95 100644 --- a/dev/View/Popup/Compose.js +++ b/dev/View/Popup/Compose.js @@ -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); diff --git a/dev/View/Popup/Domain.js b/dev/View/Popup/Domain.js index dce54a20c..2ed67bd00 100644 --- a/dev/View/Popup/Domain.js +++ b/dev/View/Popup/Domain.js @@ -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); } } diff --git a/dev/View/User/SystemDropDown.js b/dev/View/User/SystemDropDown.js index 20060e5ff..0ae3c2af1 100644 --- a/dev/View/User/SystemDropDown.js +++ b/dev/View/User/SystemDropDown.js @@ -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();