Code

Kind: global class

new Code(pubsub, name, raw_code)

The Code object provides API for processing raw JavaScript code.

Param Type Description
pubsub Pubsub Pubsub interface the code should use
name string Name of the code (e.g. file name)
raw_code string String content of the code

code.save(file_path) ⇒ Promise

Save the instrumented code as a file

Kind: instance method of Code
Returns: Promise - - On successful write, the Promise resolves to file_path.

Param Type Description
file_path string the path to write to

code.run(options) ⇒ Promise

Execute a new process as a forked child process.

Kind: instance method of Code
Returns: Promise - - On successful execution, the Promise is resolved with a Process object.

Param Type Description
options object Options object used for initializing the Process object.

Code.readMetadata(raw_code) ⇒ object

Standalone static function for reading ThingsJS metadata from raw code

Kind: static method of Code
Returns: object - - Object representing the YAML metadata from the code

Param Type Description
raw_code string Raw user code in UTF-8 string

Code.instrument(pubsub, code_name, raw_code) ⇒ string

Instrument raw JavaScript code and return a live-migratable version

Kind: static method of Code
Returns: string - - Instrumented (live-migratable) user code in UTF-8 string

Param Type Description
pubsub Pubsub The Pubsub instance to bind to the program instance
code_name string The name to assign to the program instance
raw_code string Raw user code in UTF-8 string

Code.fromString(pubsub, code_name, raw_code) ⇒ Code

Create a new Code object from raw JavaScript code provided as a utf-8 string

Kind: static method of Code
Returns: Code - Returns a new Code instance

Param Type Description
pubsub Pubsub Pubsub object to use for instrumentation - this determines which Pubsub service a Process connects to
code_name string Name to assign the code (e.g. factorial.js)
raw_code string JavaScript code string

Code.fromFile(file_path)

Create a new Code object from file path

Kind: static method of Code

Param Type Description
file_path string the path to the raw JS file

Code.fromSnapshot(snapshot) ⇒ Code

Create a new Code object from given Snapshot object

Kind: static method of Code
Returns: Code - Returns a new Code instance

Param Type Description
snapshot object The Snapshot object produced when Process.snapshot() is called

Code.fromSnapshotFile(snapshot_path) ⇒ Code

Create a new Code object from given Snapshot file. This static method calls Code.fromSnapshot after reading from file.

Kind: static method of Code
Returns: Code - Returns a new Code instance

Param Type Description
snapshot_path string The path to the snapshot file

results matching ""

    No results matching ""