Skip to content

Commit 8e4eee8

Browse files
authored
Minor JS compiler cleanups. NFC (#26610)
- Use `.entries` where possible - Use `const` where possible.
1 parent 34f6bcf commit 8e4eee8

4 files changed

Lines changed: 5 additions & 6 deletions

File tree

src/jsifier.mjs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -286,8 +286,7 @@ function handleI64Signatures(symbol, snippet, sig, i53abi, isAsyncFunction) {
286286
error(`handleI64Signatures: signature '${sig}' too long for ${symbol}(${argNames.join(', ')})`);
287287
return snippet;
288288
}
289-
for (let i = 0; i < argNames.length; i++) {
290-
const name = argNames[i];
289+
for (const [i, name] of argNames.entries()) {
291290
// If sig is shorter than argNames list then argType will be undefined
292291
// here, which will result in the default case below.
293292
const argType = sig[i + 1];

src/parseTools.mjs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ export function preprocess(filename) {
113113

114114
pushCurrentFile(filename);
115115
try {
116-
for (let [i, line] of lines.entries()) {
116+
for (const [i, line] of lines.entries()) {
117117
if (isHtml) {
118118
if (line.includes('<style') && !inStyle) {
119119
inStyle = true;
@@ -1176,7 +1176,7 @@ function pthreadDetection() {
11761176

11771177
function makeExportAliases() {
11781178
var res = ''
1179-
for (var [alias, ex] of Object.entries(nativeAliases)) {
1179+
for (const [alias, ex] of Object.entries(nativeAliases)) {
11801180
if (ASSERTIONS) {
11811181
res += ` assert(wasmExports['${ex}'], 'alias target "${ex}" not found in wasmExports');\n`;
11821182
}

src/pthread_esm_startup.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ self.onmessage = async (msg) => {
4949
// Now that the import is completed the main program will have installed
5050
// its own `onmessage` handler and replaced our handler.
5151
// Now we can dispatch any queued messages to this new handler.
52-
for (let msg of messageQueue) {
52+
for (const msg of messageQueue) {
5353
await self.onmessage(msg);
5454
}
5555

src/utility.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ export function mergeInto(obj, other, options = null) {
167167
`JS library directive ${key}=${deps} is of type '${type}', but it should be an array`,
168168
);
169169
}
170-
for (let dep of deps) {
170+
for (const dep of deps) {
171171
if (dep && typeof dep !== 'string' && typeof dep !== 'function') {
172172
error(
173173
`__deps entries must be of type 'string' or 'function' not '${typeof dep}': ${key}`,

0 commit comments

Comments
 (0)