Function default

  • Executes code in either "transpile" or "interpreter" mode.

    Type Parameters

    • T extends "transpile" | "interpreter"

      The mode of execution, either "transpile" or "interpreter".

    Parameters

    • code: string

      The source code to be processed.

    • mode: T

      Specifies the execution mode:

      • "transpile": Transpiles the code and returns the generated output.
      • "interpreter": Interprets the code and returns the execution result.
    • Optionalopts: Partial<T extends "transpile" ? ITranspilerOptions : IInterpreterOptions>

      Optional configuration object:

      • For "transpile", accepts Partial<ITranspilerOptions>.
      • For "interpreter", accepts Partial<IInterpreterOptions>.

    Returns T extends "transpile"
        ? ReturnType<Transpiler["run"]>
        : T extends "interpreter" ? ReturnType<Interpreter["run"]> : never

    Depending on the mode parameter:

    • "transpile": Returns an object containing the transpiled code and execution time.
    • "interpreter": Returns an object containing the internal state and output of the interpreter.

    If the mode is neither "transpile" nor "interpreter".