Skip to content

Commit 56d7870

Browse files
authored
[jsifier] Simplify isFunction usage. NFC (emscripten-core#25492)
Split out from emscripten-core#25491
1 parent abdfee8 commit 56d7870

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/jsifier.mjs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -642,7 +642,7 @@ function(${args}) {
642642
}
643643
});
644644

645-
let isFunction = false;
645+
const isFunction = typeof snippet == 'function';
646646
let isNativeAlias = false;
647647

648648
const postsetId = symbol + '__postset';
@@ -680,8 +680,7 @@ function(${args}) {
680680
} else if (typeof snippet == 'object') {
681681
snippet = stringifyWithFunctions(snippet);
682682
addImplicitDeps(snippet, deps);
683-
} else if (typeof snippet == 'function') {
684-
isFunction = true;
683+
} else if (isFunction) {
685684
snippet = processLibraryFunction(snippet, symbol, mangled, deps, isStub);
686685
addImplicitDeps(snippet, deps);
687686
if (CHECK_DEPS && !isUserSymbol) {
@@ -727,6 +726,7 @@ function(${args}) {
727726
// Handle arrow functions
728727
contentText = `var ${mangled} = ` + contentText + ';';
729728
} else if (contentText.startsWith('class ')) {
729+
// Handle class declarations (which also have typeof == 'function'.)
730730
contentText = contentText.replace(/^class /, `class ${mangled} `);
731731
} else {
732732
// Handle regular (non-arrow) functions

0 commit comments

Comments
 (0)