Skip to content

External Higher Order Functions #130

@FynnMazurkiewicz

Description

@FynnMazurkiewicz

Hey everyone! 😊

I'm trying to use higher order functions.
I created a higher-order function outside of the interpreter and exposed it to the sandbox.
However, this fails because the higher order function receives the psuedoFunction and therefore can't call it (TypeError: fn is not a function).

A minimal test case:

var myCode = 'wrapper(function(){});';
var initFunc = function(interpreter, scope) {
    var wrapper = function(fn) {
        fn();
    };
    interpreter.setProperty(scope, 'wrapper',
        interpreter.createNativeFunction(wrapper));
};
var myInterpreter = new Interpreter(myCode, initFunc);
myInterpreter.run();

I couldn't find any examples or documentation on how to handle this.
Sandboxed higher order functions work fine, of course.

Not sure if this is intended behaviour, but I would be more than thankful for any leads.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions