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.
Classes
Type Definitions
AfterRunCB()
Callback invoked after running a task (regardless of success or failure)
BeforeRunCB()
Callback invoked before running a 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
|
- Source:
- See:
Config
Javascript session configuration.
Properties:
Name | Type | Attributes | Description |
---|---|---|---|
awaitExecution |
boolean |
<optional> |
Enable automatic await if the execution result is a promise. Default: false. |
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
|
- 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
|
- 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
|
||||||||||||||||||||||||||||||||||
doc |
<optional> |
Defined only for calls to module:nel~inspect that succeed
to find documentation for a
Javascript expression
Properties
|
- 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:
- module:nel~LogMessage | module:nel~RequestMessage | module:nel~DisplayMessage | module:nel~StatusMessage | module:nel~StdoutMessage | module:nel~StderrMessage | module:nel~ErrorMessage | module:nel~SuccessMessage
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 |
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 |
OnSuccessCB
Callback invoked with the result of a task
Type:
- module:nel~OnExecutionSuccessCB | module:nel~OnCompletionSuccessCB | module:nel~OnInspectionSuccessCB | module:nel~OnNameListSuccessCB
ReplyMessage
Reply message
Properties:
Name | Type | Attributes | Description |
---|---|---|---|
input |
string |
<optional> |
Input reply |
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
|
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:
- module:nel~ExecutionMessage | module:nel~CompletionMessage | module:nel~InspectionMessage | module:nel~NameListMessage
- Source:
- See:
Transpiler(code) → {string|Promise.<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 | Promise.<string>