refactor: use for...of loop instead of traditional for loop (#1840)
This commit is contained in:
parent
fc21d1cae3
commit
e188daab91
|
@ -401,8 +401,8 @@ export const useSlashCommandProcessor = (
|
||||||
const descLines = server.description.trim().split('\n');
|
const descLines = server.description.trim().split('\n');
|
||||||
if (descLines) {
|
if (descLines) {
|
||||||
message += ':\n';
|
message += ':\n';
|
||||||
for (let i = 0; i < descLines.length; i++) {
|
for (const descLine of descLines) {
|
||||||
message += ` ${greenColor}${descLines[i]}${resetColor}\n`;
|
message += ` ${greenColor}${descLine}${resetColor}\n`;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
message += '\n';
|
message += '\n';
|
||||||
|
@ -431,8 +431,8 @@ export const useSlashCommandProcessor = (
|
||||||
const descLines = tool.description.trim().split('\n');
|
const descLines = tool.description.trim().split('\n');
|
||||||
if (descLines) {
|
if (descLines) {
|
||||||
message += ':\n';
|
message += ':\n';
|
||||||
for (let i = 0; i < descLines.length; i++) {
|
for (const descLine of descLines) {
|
||||||
message += ` ${greenColor}${descLines[i]}${resetColor}\n`;
|
message += ` ${greenColor}${descLine}${resetColor}\n`;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
message += '\n';
|
message += '\n';
|
||||||
|
@ -457,8 +457,8 @@ export const useSlashCommandProcessor = (
|
||||||
.trim()
|
.trim()
|
||||||
.split('\n');
|
.split('\n');
|
||||||
if (paramsLines) {
|
if (paramsLines) {
|
||||||
for (let i = 0; i < paramsLines.length; i++) {
|
for (const paramsLine of paramsLines) {
|
||||||
message += ` ${greenColor}${paramsLines[i]}${resetColor}\n`;
|
message += ` ${greenColor}${paramsLine}${resetColor}\n`;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -561,8 +561,8 @@ export const useSlashCommandProcessor = (
|
||||||
|
|
||||||
// If there are multiple lines, add proper indentation for each line
|
// If there are multiple lines, add proper indentation for each line
|
||||||
if (descLines) {
|
if (descLines) {
|
||||||
for (let i = 0; i < descLines.length; i++) {
|
for (const descLine of descLines) {
|
||||||
message += ` ${greenColor}${descLines[i]}${resetColor}\n`;
|
message += ` ${greenColor}${descLine}${resetColor}\n`;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -34,10 +34,10 @@ export function isBinary(
|
||||||
|
|
||||||
const sample = data.length > sampleSize ? data.subarray(0, sampleSize) : data;
|
const sample = data.length > sampleSize ? data.subarray(0, sampleSize) : data;
|
||||||
|
|
||||||
for (let i = 0; i < sample.length; i++) {
|
for (const byte of sample) {
|
||||||
// The presence of a NULL byte (0x00) is one of the most reliable
|
// The presence of a NULL byte (0x00) is one of the most reliable
|
||||||
// indicators of a binary file. Text files should not contain them.
|
// indicators of a binary file. Text files should not contain them.
|
||||||
if (sample[i] === 0) {
|
if (byte === 0) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue