Module: nel

Module `nel` provides a Javascript REPL session. A Javascript session can be used to run Javascript code within `Node.js`, pass the result to a callback function and even capture its `stdout` and `stderr` streams.
Source:

Classes

Session

Type Definitions

AfterRunCB()

Callback invoked after running a task (regardless of success or failure)
Source:
See:
  • module:nel~Task

BeforeRunCB()

Callback invoked before running a task
Source:
See:
  • module:nel~Task

CompletionMessage

Results of a completion request
Properties:
Name Type Attributes Description
id number <optional>
Execution context id (deleted before passing the message onto the API user)
completion
Properties
Name Type Description
list Array.<String> Array of completion matches
code String Javascript code to be completed
cursorPos Integer Cursor position within `completion.code`
matchedText String Text within `completion.code` that has been matched
cursorStart Integer Position of the start of `completion.matchedText` within `completion.code`
cursorEnd Integer Position of the end of `completion.matchedText` within `completion.code`
Source:
See:

Config

Javascript session configuration.
Properties:
Name Type Attributes Description
cwd string <optional>
Session current working directory
transpile module:nel~Transpiler <optional>
Function that transpiles the request code into Javascript that can be run by the Node.js session.
Source:
See:

ErrorMessage

Error thrown when running a task within a session
Properties:
Name Type Attributes Description
id number <optional>
Execution context id (deleted before passing the message onto the API user)
end boolean <optional>
Flag to terminate the execution context
error
Properties
Name Type Description
ename String Error name
evalue String Error value
traceback Array.<String> Error traceback
Source:
See:

ExecutionMessage

MIME representations of the result of an execution request
Properties:
Name Type Attributes Description
id number <optional>
Execution context id (deleted before the message reaches the API user)
end boolean <optional>
Flag to terminate the execution context
mime
Properties
Name Type Attributes Description
"text/plain" string <optional>
Result in plain text
"text/html" string <optional>
Result in HTML format
"image/svg+xml" string <optional>
Result in SVG format
"image/png" string <optional>
Result as PNG in a base64 string
"image/jpeg" string <optional>
Result as JPEG in a base64 string
Source:
See:

InspectionMessage

Results of an inspection request
Properties:
Name Type Attributes Description
id number <optional>
Execution context id (deleted before passing the message onto the API user)
inspection
Properties
Name Type Attributes Description
code String Javascript code to be inspected
cursorPos Integer Cursor position within `inspection.code`.
matchedText String Text within `inspection.code` that has been matched as an expression.
string String String representation
type String Javascript type
constructorList Array.<String> <optional>
List of constructors (not defined for `null` or `undefined`).
length Integer <optional>
Length property (if present)
doc <optional>
Defined only for calls to module:nel~inspect that succeed to find documentation for a Javascript expression
Properties
Name Type Attributes Description
description String Description
usage String <optional>
Usage
url String Link to the documentation source
Source:
See:

KillCB(codeopt, signalopt)

Callback run after the session server has been killed
Parameters:
Name Type Attributes Description
code Number <optional>
Exit code from session server if exited normally
signal String <optional>
Signal passed to kill the session server
Source:
See:

Message

Message received from the session server
Type:
Source:

OnCompletionSuccessCB(result)

Callback run with the result of an completion request
Parameters:
Name Type Description
result module:nel~CompletionMessage Completion request results
Source:
See:

OnDisplayCB(update)

Callback run with a display update
Parameters:
Name Type Description
update module:nel~DisplayMessage Display ID and MIME bundle
Source:
See:

OnErrorCB(error)

Callback invoked with the error obtained while running a task
Parameters:
Name Type Description
error module:nel~ErrorResult
Source:
See:
  • module:nel~Task

OnExecutionSuccessCB(result)

Callback run with the result of an execution request
Parameters:
Name Type Description
result module:nel~ExecutionMessage MIME representations
Source:
See:

OnInspectionSuccessCB(result)

Callback run with the result of an inspection request
Parameters:
Name Type Description
result module:nel~InspectionMessage Inspection request result
Source:
See:

OnReplyCB(reply)

Callback run with a reply
Parameters:
Name Type Description
reply module:nel~ReplyMessage Reply
Source:
See:

OnRequestCB(request, onReply)

Callback run with a request
Parameters:
Name Type Description
request module:nel~RequestMessage Request
onReply module:nel~onReplyCB Callback invoked with the reply
Source:
See:

OnStdioCB(data)

Callback invoked with the data written on `process.stdout` or `process.stderr` after a request to the server.
Parameters:
Name Type Description
data string
Source:
See:
  • module:nel~Task

OnSuccessCB

Callback invoked with the result of a task
Type:
Source:
See:
  • module:nel~Task

ReplyMessage

Reply message
Properties:
Name Type Attributes Description
input string <optional>
Input reply
Source:

RequestMessage

Request message
Properties:
Name Type Attributes Description
id number <optional>
Execution context id (deleted before the message reaches the API user)
request object
Properties
Name Type Attributes Description
id number <optional>
Request id (deleted before reaching the API user)
input object <optional>
Input request
Properties
Name Type Attributes Description
prompt string <optional>
Prompt message
password boolean <optional>
Treat input as a password
clear object <optional>
Request to clear the output
Properties
Name Type Attributes Description
wait boolean <optional>
Whether to wait for an update before clearing the output
Source:

RestartCB(codeopt, signalopt)

Callback run after the session server has been restarted
Parameters:
Name Type Attributes Description
code Number <optional>
Exit code from old session if exited normally
signal String <optional>
Signal passed to kill the old session
Source:
See:

SuccessMessage

Request result
Type:
Source:
See:

Transpiler(code) → {string}

Function that transpiles the request code into Javascript that can be run by the Node.js session.
Parameters:
Name Type Description
code string Request code
Source:
See:
Returns:
Transpiled code
Type
string