Repository navigation
Conversation
kripken
reviewed
Nov 30, 2026
| * 2. `addFunction(name, heapType, varTypes, body)` - when you already have a signature heap type created by a type builder | ||
| */ | ||
| self['addFunction'] = function (name, arg1, arg2, arg3, arg4) { | ||
| if (arguments.length >= 5) { |
Member
There was a problem hiding this comment.
Seems like this would be the first place we use arguments.length to disambiguate an API. I'm not necessarily opposed to this, but what do you think about other options like a different name addFunctionWithType - ?
Contributor
Author
There was a problem hiding this comment.
arguments.length is non-standard (and also probably not recommended), I just used it to get the job done. I can either change it to if (arg4 !== undefined) or just make it a completely separate function like you suggest. I figured both functions are so similar that multiple overloads under the same name would reduce surface area, but if you think it warrants a separate API point then I can split it.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds JS support for
BinaryenAddFunctionWithHeapTypeby adding a new overloadto the
Module#addFunctionmethod, taking only four arguments:This is a non-breaking change. When users don’t have a heap type,
they can still call the five-argument form: