javascript: make FFI work with HOFs