Home Reference Source
public class | source

NodeContext

Extends:

ContextJavascriptContext → NodeContext

A Node.js context for executing Javascript code

Method Summary

Public Methods
public

async compileFile(file: String): Object

Compile a Javascript source code file

public

async compileLibrary(src: String, dest: String, minify: Boolean): {"type": string, "name": *, "funcs": *, "bundle": *}

Compile a Stencila library so that it can be loaded either into a NodeContext or another JavascriptContext (e.g one embedded into a Stencila web or desktop interface).

public

async executeLibrary(library_: *): {"type": string, "name": *, "funcs": *}

Inherited Summary

From class Context
public get

host: *

public get

id: *

public get

location: {"context": *, "host": *, "machine": *}

public get

name: *

private

_host: *

private
private

_name: *

private
public

async compile(cell: *): {"source": *, "expr": *, "global": *, "options": *, "inputs": *, "outputs": *, "messages": *}

public

async evaluate(node: *): *

public

async execute(cell: *): *

public

async libraries(): {}

public

async pack(value: *): *

public

async packPackage(value: *): {"type": *, "data": *}

public

async packPointer(objectPattern: {"type": *, "name": *, "preview": *}): {"type": *, "path": *, "preview": *}

public

async provide(what: *): *

public

async resolve(what: *): *

public

async unpack(node: Object): [type]

Unpack a data node into a native data value

public

async unpackPackage(pkg: *): *

public

async unpackPointer(pointer: *): *

From class JavascriptContext
private

Libraries registered in this context

private

Variables residing in this context

public

async compile(cell: *, internal: boolean): *

Compile a cell

public

async evaluateCall(call: *): *

public

async evaluateGet(get: *): *

public

async execute(cell: *): *

public

async libraries(): *

Get the libraries registered in this context

public

async pack(value: *): *

Pack a value

public

async variables(): *

Get the variables residing in this context

private

_compileFunction(name: *, decl: *, source: *, docs: *): *

Public Methods

public async compileFile(file: String): Object source

Compile a Javascript source code file

Params:

NameTypeAttributeDescription
file String

File path

Return:

Object

Function object

public async compileLibrary(src: String, dest: String, minify: Boolean): {"type": string, "name": *, "funcs": *, "bundle": *} source

Compile a Stencila library so that it can be loaded either into a NodeContext or another JavascriptContext (e.g one embedded into a Stencila web or desktop interface).

Creates a Javascript bundle which exports both function definitions and a function specification objects.

Params:

NameTypeAttributeDescription
src String

Path to library folder

dest String

Destination

minify Boolean

Should the bundle be minified? (defaults to true)

Return:

{"type": string, "name": *, "funcs": *, "bundle": *}

public async executeLibrary(library_: *): {"type": string, "name": *, "funcs": *} source

Params:

NameTypeAttributeDescription
library_ *

Return:

{"type": string, "name": *, "funcs": *}