Gathering detailed insights and metrics for nel
Gathering detailed insights and metrics for nel
Gathering detailed insights and metrics for nel
Gathering detailed insights and metrics for nel
network-error-logging
NEL Middleware for Express
bootstrap-italia
Bootstrap Italia è un tema Bootstrap 5 per la creazione di applicazioni web nel pieno rispetto delle linee guida di design per i siti internet e i servizi digitali della PA
@kurtharriger/nel
Node.js Evaluation Loop (NEL): npm package to implement a Node.js REPL session
@stackhouseos/flower-client
Libreria per la visualizzazione del flower nel progetto, basato sugli elements generati dal builder
npm install nel
75.6
Supply Chain
99.1
Quality
75.8
Maintenance
100
Vulnerability
100
License
Module System
Unable to determine the module system for this package.
Min. Node Version
Typescript Support
Node Version
NPM Version
27 Stars
134 Commits
12 Forks
2 Watching
2 Branches
2 Contributors
Updated on 17 Oct 2024
JavaScript (100%)
Cumulative downloads
Total Downloads
Last day
-40.7%
80
Compared to previous day
Last week
-23.2%
502
Compared to previous week
Last month
16.5%
2,355
Compared to previous month
Last year
-23.6%
25,571
Compared to previous year
NEL
is an npm module for running
Node.js REPL sessions.
NEL
is a spin-off library from
IJavascript. This fact explains some
of the design decisions in NEL
, such as returning results in MIME format, and
the functionality provided for completion and inspection of Javascript
expressions. See the section on usage for more details.
NEL
is used by the following Jupyter kernels:
Node.js
session. The result can be formatted
as:
HTML
, SVG
, PNG
...)NEL v1.3.0
: API enhancement (added option awaitExecution)NEL v1.2.0
: API enhancement (Session#transpile may return a Promise)NEL v1.1.0
: API enhancement (added $$.clear({wait}))NEL v1.0.0
: Stable APINEL v0.5.6
: API enhancement (added $$.input() and onRequest callback)NEL v0.5.5
: Accept Promises as outputNEL v0.5.4
: API enhancement (added $$.display() and onDisplay callback)NEL v0.5
: API enhancement (added transpile option)NEL v0.4
: API enhancement (added onStdout and onStderr callbacks)NEL v0.3
: New API (simplify API by hiding type module:nel~Task)NEL v0.2
: API change (removed Session#executionCount)NEL v0.1.1
: API enhancement (experimental $$mimer$$
and $$defaultMimer$$
)NEL v0.1
: Output change (changed function output)NEL v0.0
: Initial release1npm install nel
The documentation generated by JSDoc can be found here.
1// Load `nel` module 2var nel = require("nel"); 3 4// Setup a new Javascript session 5var session = new nel.Session(); 6 7// Example of an execution request 8// Output: 9// { mime: { 'text/plain': '\'Hello, World!\'' } } 10var code = "['Hello', 'World!'].join(', ');"; 11session.execute(code, { 12 onSuccess: console.log, 13 onError: console.error, 14});
1// Example of throwing an exception 2// Output: 3// { error: 4// { ename: 'Error', 5// evalue: 'Hello, World!', 6// traceback: 7// [ 'Error: Hello, World!', 8// ' at evalmachine.<anonymous>:1:7', 9// ' at run ([eval]:182:19)', 10// ' at onMessage ([eval]:63:41)', 11// ' at process.EventEmitter.emit (events.js:98:17)', 12// ' at handleMessage (child_process.js:318:10)', 13// ' at Pipe.channel.onread (child_process.js:345:11)' ] } } 14code = "throw new Error('Hello, World!');"; 15session.execute(code, { 16 onSuccess: console.log, 17 onError: console.error, 18});
stdout
and stderr
1// Example of use of console.log() 2// Output: 3// Hello, World! 4// 5// { mime: { 'text/plain': 'undefined' } } 6code = "console.log('Hello, World!');"; 7session.execute(code, { 8 onSuccess: console.log, 9 onError: console.error, 10 onStdout: console.log, 11 onStderr: console.error, 12});
onDisplay
callbackThe Jupyter messaging protocol
introduces the concept of display. A display is very much like an execution
result. It is associated with an execution request and in protocol version 5.1
and above it can be assigned an ID for subsequent updates. Here's an example of
the support provided by NEL
:
1// Example using onDisplay callback 2// Output: 3// { mime: { 'text/plain': 'Hello, World!' } } 4code = "$$.display().text('Hello, World!');"; 5session.execute(code, { 6 onDisplay: console.log, 7}); 8 9// Example using a display ID 10// Output: 11// { display_id: 'test', mime: { 'text/plain': 'Hello, World!' } } 12code = "$$.display('test').text('Hello, World!');"; 13session.execute(code, { 14 onDisplay: console.log, 15});
onRequest
callback and $$.input(options, callback)
The Jupyter messaging protocol
defines an stdin socket, so that a kernel can request an input from the user.
NEL
defines $$.input(options, callback)
to create such a request.
Here are two examples (first one passing a callback to $$.input
; second one
using a Promise
returned by $$.input()
):
1// Example passing a callback to $$.input() 2// Output: 3// { mime: { 'text/plain': '\'opensesame\'' } } 4code = "$$.input({prompt:'?', password: true}, function(error, reply) {$$.done(reply)});"; 5 6session.execute(code, { 7 onRequest: function(request, onReply) { 8 assert(request.input.prompt === "?"); 9 assert(request.input.password === true); 10 11 onReply({input: "opensesame"}); 12 }, 13 onSuccess: console.log, 14}); 15 16// Example using the Promise returned by $$.input() 17// Output: 18// { mime: { 'text/plain': '\'opensesame\'' } } 19code = "(function($$) {$$.input({prompt:'?', password: true}).then($$.done);})($$);"; 20 21session.execute(code, { 22 onRequest: function(request, onReply) { 23 assert(request.input.prompt === "?"); 24 assert(request.input.password === true); 25 26 onReply({input: "opensesame"}); 27 }, 28 onSuccess: console.log, 29});
onRequest
callback and $$.clear(options)
The Jupyter messaging protocol
defines the message clear_output
for kernels to request the output of a cell
to be cleared. NEL
provides $$.clear(options)
to implement such a request.
Here's an example showing the use:
1// Example using $$.clear(options) 2// Output: 3// { clear: { wait: true } } 4code = "$$.clear({wait: true});"; 5 6session.execute(code, { 7 onRequest: console.log 8});
A session may return results in MIME formats other than 'text/plain'.
1// HTML example 2// Output: 3// { mime: { 'text/html': '<div style=\'background-color:olive;width:50px;height:50px\'></div>' } } 4code = "$$html$$ = \"<div style='background-color:olive;width:50px;height:50px'></div>\";"; 5session.execute(code, { 6 onSuccess: console.log, 7 onError: console.error, 8}); 9 10// SVG example 11// Output: 12// { mime: { 'image/svg+xml': '<svg><rect width=80 height=80 style=\'fill: orange;\'/></svg>' } } 13code = "$$svg$$ = \"<svg><rect width=80 height=80 style='fill: orange;'/></svg>\";"; 14session.execute(code, { 15 onSuccess: console.log, 16 onError: console.error, 17}); 18 19// PNG example 20code = "$$png$$ = require('fs').readFileSync('image.png').toString('base64');"; 21session.execute(code, { 22 onSuccess: console.log, 23 onError: console.error, 24}); 25 26// JPEG example 27code = "$$jpeg$$ = require('fs').readFileSync('image.jpg').toString('base64');"; 28session.execute(code, { 29 onSuccess: console.log, 30 onError: console.error, 31}); 32 33// MIME example 34code = "$$mime$$ = {\"text/html\": \"<div style='background-color:olive;width:50px;height:50px'></div>\"};"; 35session.execute(code, { 36 onSuccess: console.log, 37 onError: console.error, 38});
When the result of an execution request is a Promise
, NEL
enables
asynchronous execution automatically and waits for the Promise
to resolve:
1// Example returning a Promise 2// Output: 3// { mime: { 'text/plain': '\'Hello, World!\'' } } 4code = "Promise.resolve('Hello, World!');"; 5 6session.execute(code, { 7 onSuccess: console.log, 8});
NEL
can parse simple Javascript variable expressions and generate a list of
completion options:
1session.complete( 2 "set", // code 3 3, // cursorPos 4 { 5 onSuccess: console.log, 6 onError: console.error, 7 } 8); 9 10// Output: 11// { completion: 12// { list: [ 'setImmediate', 'setInterval', 'setTimeout' ], 13// code: 'set', 14// cursorPos: 3, 15// matchedText: 'set', 16// cursorStart: 0, 17// cursorEnd: 3 } }
Note that the cursor position can be located anywhere within the Javascript code:
1session.complete( 2 "set", // code 3 2, // cursorPos 4 { 5 onSuccess: console.log, 6 onError: console.error, 7 } 8); 9 10// Output: 11// { completion: 12// { list: [ 'setImmediate', 'setInterval', 'setTimeout' ], 13// code: 'set', 14// cursorPos: 2, 15// matchedText: 'se', 16// cursorStart: 0, 17// cursorEnd: 3 } }
NEL
can parse simple Javascript variable expressions and inspect their value:
1code = "var a = [1, 2, 3];"; 2session.execute(code, null, onError); 3session.inspect( 4 code, // code 5 5, // cursorPos 6 { 7 onSuccess: console.log, 8 onError: console.error, 9 } 10); 11 12// Output: 13// { inspection: 14// { string: '[ 1, 2, 3 ]', 15// type: 'Array', 16// constructorList: [ 'Array', 'Object' ], 17// length: 3, 18// code: 'var a = [1, 2, 3];', 19// cursorPos: 5, 20// matchedText: 'a' } }
NEL
can also provide relevant documentation (currently only available for
Javascript builtins):
1session.inspect( 2 "parseInt", // code 3 8, // cursorPos 4 { 5 onSuccess: console.log, 6 onError: console.error, 7 } 8); 9 10// Output: 11// { inspection: 12// { string: '[Function: parseInt]', 13// type: 'Object', 14// constructorList: [ 'Function', 'Object' ], 15// length: 2, 16// code: 'parseInt', 17// cursorPos: 8, 18// matchedText: 'parseInt' }, 19// doc: 20// { description: 'The parseInt() function parses a string argument and returns an integer of the specified radix (the base in mathematical numeral systems).', 21// url: 'https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/parseInt', 22// usage: 'parseInt(string, radix);' } }
beforeRun
and afterRun
1var beforeRun = function() { console.log("This callback runs first"); } 2code = "'I run next'"; 3var afterRun = function() { console.log("This callback runs last"); } 4session.execute(code, { 5 onSuccess: console.log, 6 onError: console.error, 7 beforeRun: beforeRun, 8 afterRun: afterRun, 9}); 10 11// Output: 12// This callback runs first 13// { mime: { 'text/plain': '\'I run next\'' } } 14// This callback runs last
First of all, thank you for taking the time to contribute. Please, read CONTRIBUTING.md and use the issue tracker for any contributions: support requests, bug reports, enhancement requests, pull requests, ...
Node.js
documentationNo vulnerabilities found.
Reason
no binaries found in the repo
Reason
0 existing vulnerabilities detected
Reason
license file detected
Details
Reason
Found 0/30 approved changesets -- score normalized to 0
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no SAST tool detected
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Score
Last Scanned on 2024-11-18
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More