node package manager
We need your input. Help make JavaScript better: Take the 2017 JavaScript Ecosystem survey »


JavaScript Engine for Sense

Build Status

This module implements a JavaScript (NodeJS) engine for Sense using Sense's Engine API. It is preinstalled on Sense.

Sense JavaScript Engine

Installation and Usage

You can install this engine locally using

npm install sense-js-engine

You can test it from the command line using

grunt test

If you install this package in your project's /home/sense, it will override the default JavaScript engine and can be used from Sense.

Implementation Overview

This module provides a complete example of how to implement an engine for Sense.

The engine evaluates code chunks in a subprocess, keeping the main process's event loop relatively free. This allows the engine to receive interrupt events and emit output while code chunks are running.

Each engine must define the chunk method that splits long strings of code into logical units such as statements and block comments. This engine's chunker uses the acorn parser with the comment-chunk-helper package.

While evaluating code chunks, the subprocess generates output, which it sends to the engine according to its type using [process.send](h ttp:// ge_sendhandle). When the subprocess has finished evaluating a code chunk, it sends an output message of type result, indicating that it is ready for the next code chunk.

The engine itself communicates with the frontend using the methods defined in the Engine API.