I am trying to place a Javascript function inside a WebAssembly.Table, where the element type of the table is required to be funcref. The following lines can be executed in node but raise an exception when I try to put the function inside the table:
table = new WebAssembly.Table({initial: 1, element: "anyfunc"})
func = function() { return 42 }
table.set(0, func)
The exception is:
TypeError: WebAssembly.Table.set(): Argument 1 is invalid for table of type funcref
Is it possible to convert from a Javascript function to a funcref?