Interface IPolyglot

Interface for Polyglot object. The functions of the Polyglot object allow you to interact with values from other polyglot languages.

Hierarchy

  • IPolyglot

Methods

Methods

  • Parses and evaluates sourceCode with the interpreter identified by languageId. The value of sourceCode is expected to be a String (or convertible to one). Returns the evaluation result.

    Returns

    the evaluation result, depending on the sourceCode and/or the semantics of the language evaluated.

    Throws

    Exceptions can occur when an invalid languageId is passed, when sourceCode cannot be evaluated by the language, or when the executed program throws an exception itself.

    Parameters

    • languageId: "js"

      identifies the language.

    • sourceCode: string

      contains the source code to be evaluated.

    Returns any

  • Exports the JavaScript value under the given key to the polyglot bindings. If the polyglot bindings already had a value identified by key, it is overwritten with the new value. The value may be any valid Polyglot value.

    Throws

    TypeError if key is not a String.

    Parameters

    • key: string

      identifier of polyglot binding that should be written.

    • value: any

      content of polyglot binding that should be written.

    Returns undefined

  • Imports the value identified by key from the polyglot bindings and returns it. If no language has exported a value identified by key, undefined is returned.

    Returns

    the value of the polyglot binding or undefined if it does not exist.

    Throws

    TypeError if key is not a String.

    Parameters

    • key: string

      identifier of polyglot binding that should be read.

    Returns any