Function compileFunction

  • Compiles a function from the given code.

    const arg = Symbol();
    const varA = Symbol();
    const varB = Symbol();

    const fn = compileFunction(
    [arg],
    [
    'var ', varA, '=123;',
    'return ', varA, '+', arg, '+', varB,
    ],
    [[varB, 456]],
    );

    fn(789); // → 1368

    Returns

    The compiled function.

    Type Parameters

    • F extends Function

    Parameters

    • argVars: Var[]

      The list of function arguments.

    • code: Code

      The body code of the function.

    • Optional bindings: Iterable<Binding> | Binding[]

      The list of variable-value pairs that are bound to the output function.

    Returns F

Generated using TypeDoc