chore(cloudcmd) lint: convert forEach to for-of

This commit is contained in:
coderaiser 2019-06-25 20:12:34 +03:00
parent 6d69cd3a48
commit fd6d384ba2
9 changed files with 25 additions and 24 deletions

View file

@ -259,9 +259,9 @@ function CloudCmdProto(DOM) {
if (!modules)
return;
modules.local.forEach((module) => {
for (const module of modules.local) {
load(null, module, doBefore[module]);
});
}
});
function baseInit(callback) {

View file

@ -36,17 +36,17 @@ function BufferProto() {
function addCutClass() {
const files = DOM.getActiveFiles();
files.forEach((element) => {
for (const element of files) {
element.classList.add(CLASS);
});
}
}
function rmCutClass() {
const files = DOM.getByClassAll(CLASS);
[...files].forEach((element) => {
for (const element of [...files]) {
element.classList.remove(CLASS);
});
}
}
function callIfEnabled(callback) {

View file

@ -60,23 +60,24 @@ function EventsProto() {
break;
case 'array':
eventName.forEach((eventName) => {
for (const eventName of eventName) {
parseArgs(eventName,
element,
listener,
callback);
});
}
break;
case 'object':
Object.keys(eventName).forEach((name) => {
for (const name of Object.keys(eventName)) {
const eventListener = eventName[name];
parseArgs(name,
element,
eventListener,
callback);
});
}
break;
}

View file

@ -48,10 +48,10 @@ module.exports.ajax = (params) => {
xhr.open(type, p.url, true);
Object.keys(headers).forEach((name) => {
for (const name of Object.keys(headers)) {
const value = headers[name];
xhr.setRequestHeader(name, value);
});
}
if (p.responseType)
xhr.responseType = p.responseType;

View file

@ -206,12 +206,12 @@ async function onChange(el) {
}
function onSave(obj) {
Object.keys(obj).forEach((name) => {
for (const name of Object.keys(obj)) {
const data = obj[name];
CloudCmd._config(name, data);
input.setValue(name, data, Element);
});
}
}
async function saveHttp(obj) {

View file

@ -267,7 +267,7 @@ function download(type) {
if (!files.length)
return alertNoFiles();
files.forEach((file) => {
for (const file of files) {
const selected = DOM.isSelected(file);
const isDir = DOM.isCurrentIsDir(file);
const path = DOM.getCurrentPath(file);
@ -302,7 +302,7 @@ function download(type) {
if (selected)
DOM.toggleSelectedFile(file);
});
}
}
function getCurrentPosition() {

View file

@ -10,23 +10,23 @@ const Entities = {
const keys = Object.keys(Entities);
module.exports.encode = (str) => {
keys.forEach((code) => {
for (const code of keys) {
const char = Entities[code];
const reg = RegExp(char, 'g');
str = str.replace(reg, code);
});
}
return str;
};
module.exports.decode = (str) => {
keys.forEach((code) => {
for (const code of keys) {
const char = Entities[code];
const reg = RegExp(code, 'g');
str = str.replace(reg, char);
});
}
return str;
};

View file

@ -62,7 +62,7 @@ module.exports = (params) => {
checkPlugins(plugins);
keys.forEach((name) => {
for (const name of keys) {
let value = options[name];
if (/root/.test(name))
@ -75,7 +75,7 @@ module.exports = (params) => {
value = prefixer(value);
config(name, value);
});
}
config('console', defaultValue(config, 'console', options));
config('configDialog', defaultValue(config, 'configDialog', options));

View file

@ -229,9 +229,9 @@ async function patchConfig(manage, {name, request, response, cache}) {
}
function traverse([manage, json]) {
Object.keys(json).forEach((name) => {
for (const name of Object.keys(json)) {
manage(name, json[name]);
});
}
}
module.exports._cryptoPass = cryptoPass;