From 4a96ae98012d17f9dcfb48d7d4ce4027f2f78003 Mon Sep 17 00:00:00 2001 From: Sam Clegg Date: Fri, 3 Oct 2025 17:07:03 -0700 Subject: [PATCH] [jsifier] Simplify `isFunction` usage. NFC --- src/jsifier.mjs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/jsifier.mjs b/src/jsifier.mjs index 0f756027531cc..6d9f25560f09a 100644 --- a/src/jsifier.mjs +++ b/src/jsifier.mjs @@ -642,7 +642,7 @@ function(${args}) { } }); - let isFunction = false; + const isFunction = typeof snippet == 'function'; let isNativeAlias = false; const postsetId = symbol + '__postset'; @@ -680,8 +680,7 @@ function(${args}) { } else if (typeof snippet == 'object') { snippet = stringifyWithFunctions(snippet); addImplicitDeps(snippet, deps); - } else if (typeof snippet == 'function') { - isFunction = true; + } else if (isFunction) { snippet = processLibraryFunction(snippet, symbol, mangled, deps, isStub); addImplicitDeps(snippet, deps); if (CHECK_DEPS && !isUserSymbol) { @@ -727,6 +726,7 @@ function(${args}) { // Handle arrow functions contentText = `var ${mangled} = ` + contentText + ';'; } else if (contentText.startsWith('class ')) { + // Handle class declarations (which also have typeof == 'function'.) contentText = contentText.replace(/^class /, `class ${mangled} `); } else { // Handle regular (non-arrow) functions