mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-01-23 02:35:49 +00:00
chore(cloudcmd) lint: convert forEach to for-of
This commit is contained in:
parent
6d69cd3a48
commit
fd6d384ba2
9 changed files with 25 additions and 24 deletions
|
|
@ -259,9 +259,9 @@ function CloudCmdProto(DOM) {
|
||||||
if (!modules)
|
if (!modules)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
modules.local.forEach((module) => {
|
for (const module of modules.local) {
|
||||||
load(null, module, doBefore[module]);
|
load(null, module, doBefore[module]);
|
||||||
});
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
function baseInit(callback) {
|
function baseInit(callback) {
|
||||||
|
|
|
||||||
|
|
@ -36,17 +36,17 @@ function BufferProto() {
|
||||||
function addCutClass() {
|
function addCutClass() {
|
||||||
const files = DOM.getActiveFiles();
|
const files = DOM.getActiveFiles();
|
||||||
|
|
||||||
files.forEach((element) => {
|
for (const element of files) {
|
||||||
element.classList.add(CLASS);
|
element.classList.add(CLASS);
|
||||||
});
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function rmCutClass() {
|
function rmCutClass() {
|
||||||
const files = DOM.getByClassAll(CLASS);
|
const files = DOM.getByClassAll(CLASS);
|
||||||
|
|
||||||
[...files].forEach((element) => {
|
for (const element of [...files]) {
|
||||||
element.classList.remove(CLASS);
|
element.classList.remove(CLASS);
|
||||||
});
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function callIfEnabled(callback) {
|
function callIfEnabled(callback) {
|
||||||
|
|
|
||||||
|
|
@ -60,23 +60,24 @@ function EventsProto() {
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'array':
|
case 'array':
|
||||||
eventName.forEach((eventName) => {
|
for (const eventName of eventName) {
|
||||||
parseArgs(eventName,
|
parseArgs(eventName,
|
||||||
element,
|
element,
|
||||||
listener,
|
listener,
|
||||||
callback);
|
callback);
|
||||||
});
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'object':
|
case 'object':
|
||||||
Object.keys(eventName).forEach((name) => {
|
for (const name of Object.keys(eventName)) {
|
||||||
const eventListener = eventName[name];
|
const eventListener = eventName[name];
|
||||||
|
|
||||||
parseArgs(name,
|
parseArgs(name,
|
||||||
element,
|
element,
|
||||||
eventListener,
|
eventListener,
|
||||||
callback);
|
callback);
|
||||||
});
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -48,10 +48,10 @@ module.exports.ajax = (params) => {
|
||||||
|
|
||||||
xhr.open(type, p.url, true);
|
xhr.open(type, p.url, true);
|
||||||
|
|
||||||
Object.keys(headers).forEach((name) => {
|
for (const name of Object.keys(headers)) {
|
||||||
const value = headers[name];
|
const value = headers[name];
|
||||||
xhr.setRequestHeader(name, value);
|
xhr.setRequestHeader(name, value);
|
||||||
});
|
}
|
||||||
|
|
||||||
if (p.responseType)
|
if (p.responseType)
|
||||||
xhr.responseType = p.responseType;
|
xhr.responseType = p.responseType;
|
||||||
|
|
|
||||||
|
|
@ -206,12 +206,12 @@ async function onChange(el) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function onSave(obj) {
|
function onSave(obj) {
|
||||||
Object.keys(obj).forEach((name) => {
|
for (const name of Object.keys(obj)) {
|
||||||
const data = obj[name];
|
const data = obj[name];
|
||||||
|
|
||||||
CloudCmd._config(name, data);
|
CloudCmd._config(name, data);
|
||||||
input.setValue(name, data, Element);
|
input.setValue(name, data, Element);
|
||||||
});
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function saveHttp(obj) {
|
async function saveHttp(obj) {
|
||||||
|
|
|
||||||
|
|
@ -267,7 +267,7 @@ function download(type) {
|
||||||
if (!files.length)
|
if (!files.length)
|
||||||
return alertNoFiles();
|
return alertNoFiles();
|
||||||
|
|
||||||
files.forEach((file) => {
|
for (const file of files) {
|
||||||
const selected = DOM.isSelected(file);
|
const selected = DOM.isSelected(file);
|
||||||
const isDir = DOM.isCurrentIsDir(file);
|
const isDir = DOM.isCurrentIsDir(file);
|
||||||
const path = DOM.getCurrentPath(file);
|
const path = DOM.getCurrentPath(file);
|
||||||
|
|
@ -302,7 +302,7 @@ function download(type) {
|
||||||
|
|
||||||
if (selected)
|
if (selected)
|
||||||
DOM.toggleSelectedFile(file);
|
DOM.toggleSelectedFile(file);
|
||||||
});
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function getCurrentPosition() {
|
function getCurrentPosition() {
|
||||||
|
|
|
||||||
|
|
@ -10,23 +10,23 @@ const Entities = {
|
||||||
const keys = Object.keys(Entities);
|
const keys = Object.keys(Entities);
|
||||||
|
|
||||||
module.exports.encode = (str) => {
|
module.exports.encode = (str) => {
|
||||||
keys.forEach((code) => {
|
for (const code of keys) {
|
||||||
const char = Entities[code];
|
const char = Entities[code];
|
||||||
const reg = RegExp(char, 'g');
|
const reg = RegExp(char, 'g');
|
||||||
|
|
||||||
str = str.replace(reg, code);
|
str = str.replace(reg, code);
|
||||||
});
|
}
|
||||||
|
|
||||||
return str;
|
return str;
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports.decode = (str) => {
|
module.exports.decode = (str) => {
|
||||||
keys.forEach((code) => {
|
for (const code of keys) {
|
||||||
const char = Entities[code];
|
const char = Entities[code];
|
||||||
const reg = RegExp(code, 'g');
|
const reg = RegExp(code, 'g');
|
||||||
|
|
||||||
str = str.replace(reg, char);
|
str = str.replace(reg, char);
|
||||||
});
|
}
|
||||||
|
|
||||||
return str;
|
return str;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -62,7 +62,7 @@ module.exports = (params) => {
|
||||||
|
|
||||||
checkPlugins(plugins);
|
checkPlugins(plugins);
|
||||||
|
|
||||||
keys.forEach((name) => {
|
for (const name of keys) {
|
||||||
let value = options[name];
|
let value = options[name];
|
||||||
|
|
||||||
if (/root/.test(name))
|
if (/root/.test(name))
|
||||||
|
|
@ -75,7 +75,7 @@ module.exports = (params) => {
|
||||||
value = prefixer(value);
|
value = prefixer(value);
|
||||||
|
|
||||||
config(name, value);
|
config(name, value);
|
||||||
});
|
}
|
||||||
|
|
||||||
config('console', defaultValue(config, 'console', options));
|
config('console', defaultValue(config, 'console', options));
|
||||||
config('configDialog', defaultValue(config, 'configDialog', options));
|
config('configDialog', defaultValue(config, 'configDialog', options));
|
||||||
|
|
|
||||||
|
|
@ -229,9 +229,9 @@ async function patchConfig(manage, {name, request, response, cache}) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function traverse([manage, json]) {
|
function traverse([manage, json]) {
|
||||||
Object.keys(json).forEach((name) => {
|
for (const name of Object.keys(json)) {
|
||||||
manage(name, json[name]);
|
manage(name, json[name]);
|
||||||
});
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports._cryptoPass = cryptoPass;
|
module.exports._cryptoPass = cryptoPass;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue