From e4669963cbc7953708868ed1a6fe84b33ffc52b1 Mon Sep 17 00:00:00 2001 From: Chris Harvey <1362083+chharvey@users.noreply.github.com> Date: Mon, 13 Jul 2026 21:02:34 -0400 Subject: [PATCH 1/3] feat: merge `Module['parseTextWithFeatures']` into `Module['parseText']` deletes `Module['parseTextWithFeatures']`. update any uses accordingly. --- src/js/binaryen.js-post.js | 17 +++++------------ test/binaryen.js/kitchen-sink.js | 4 ++-- 2 files changed, 7 insertions(+), 14 deletions(-) diff --git a/src/js/binaryen.js-post.js b/src/js/binaryen.js-post.js index 103fd6d76db..085fc44f400 100644 --- a/src/js/binaryen.js-post.js +++ b/src/js/binaryen.js-post.js @@ -3382,20 +3382,13 @@ Module['readBinaryWithFeatures'] = function(data, features) { return wrapModule(ptr); }; -// Parses text format to a module -Module['parseText'] = function(text) { +// Parses s-expression text format to a module with the given feature set enabled, defaulting to MVP +Module['parseText'] = function(text, features = Module['Features']['MVP']) { const buffer = _malloc(text.length + 1); stringToAscii(text, buffer); - const ptr = handleFatalError(() => Module['_BinaryenModuleParse'](buffer)); - _free(buffer); - return wrapModule(ptr); -}; - -// Parses text format to a module with the given feature set enabled -Module['parseTextWithFeatures'] = function(text, features) { - const buffer = _malloc(text.length + 1); - stringToAscii(text, buffer); - const ptr = handleFatalError(() => Module['_BinaryenModuleParseWithFeatures'](buffer, features)); + const ptr = features === undefined + ? handleFatalError(() => Module['_BinaryenModuleParse'](buffer)) + : handleFatalError(() => Module['_BinaryenModuleParseWithFeatures'](buffer, features)); _free(buffer); return wrapModule(ptr); }; diff --git a/test/binaryen.js/kitchen-sink.js b/test/binaryen.js/kitchen-sink.js index 6f8a48d7491..6baea5157fd 100644 --- a/test/binaryen.js/kitchen-sink.js +++ b/test/binaryen.js/kitchen-sink.js @@ -1135,14 +1135,14 @@ function test_parsing_with_features() { (global $g anyref (ref.null any)) )`; - module = binaryen.parseTextWithFeatures(text, binaryen.Features.All); + module = binaryen.parseText(text, binaryen.Features.All); assert(module.validate()); console.log("module loaded from text form with features:"); console.log(module.emitText()); module.dispose(); // parse with MVP features, which should fail - module = binaryen.parseTextWithFeatures(text, binaryen.Features.MVP); + module = binaryen.parseText(text, binaryen.Features.MVP); console.log("validation with MVP features: " + module.validate()); module.dispose(); } From 3a43260814d7de72cd7a91a97acc94d43fceb34d Mon Sep 17 00:00:00 2001 From: Chris Harvey <1362083+chharvey@users.noreply.github.com> Date: Mon, 13 Jul 2026 22:41:31 -0400 Subject: [PATCH 2/3] fix: remove default value a different API is called when no `features` is provided --- src/js/binaryen.js-post.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/js/binaryen.js-post.js b/src/js/binaryen.js-post.js index 085fc44f400..94894a0acc0 100644 --- a/src/js/binaryen.js-post.js +++ b/src/js/binaryen.js-post.js @@ -3382,8 +3382,8 @@ Module['readBinaryWithFeatures'] = function(data, features) { return wrapModule(ptr); }; -// Parses s-expression text format to a module with the given feature set enabled, defaulting to MVP -Module['parseText'] = function(text, features = Module['Features']['MVP']) { +// Parses s-expression text format to a module with the given feature set enabled +Module['parseText'] = function(text, features) { const buffer = _malloc(text.length + 1); stringToAscii(text, buffer); const ptr = features === undefined From ac708114b4e064f048e994c7457a9c7cf835fcf9 Mon Sep 17 00:00:00 2001 From: Thomas Lively Date: Tue, 14 Jul 2026 11:04:21 +0200 Subject: [PATCH 3/3] Update src/js/binaryen.js-post.js --- src/js/binaryen.js-post.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/js/binaryen.js-post.js b/src/js/binaryen.js-post.js index 94894a0acc0..c97a08642b9 100644 --- a/src/js/binaryen.js-post.js +++ b/src/js/binaryen.js-post.js @@ -3382,7 +3382,7 @@ Module['readBinaryWithFeatures'] = function(data, features) { return wrapModule(ptr); }; -// Parses s-expression text format to a module with the given feature set enabled +// Parses text format to a module with the given feature set enabled. Module['parseText'] = function(text, features) { const buffer = _malloc(text.length + 1); stringToAscii(text, buffer);