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
|
|
@ -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;
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue