n-riesco / nel Goto Github PK
View Code? Open in Web Editor NEWNode.js module for running a javascript REPL session
License: Other
Node.js module for running a javascript REPL session
License: Other
Thank you for your cool things about iPython Notebook.
I just make two line modify to support CoffeeScript. It works!
function run(code) {
var compiledCode = require('coffee-script').compile(code, {bare: true})
if(DEBUG) { console.log("SM: COMPILED: ```\n", compiledCode, '\n') }
return vm.runInThisContext(compiledCode);
}
But I'm not familiar with the architecture, I'm thinking how to make it support any compiler that exists(coffeescript, babel, etc...)
Here are some ways to do it:
ijavascript --compile coffee
, compiler can provided as plugins(such as ijavascript-coffee-plugin
)Cell - Cell Type
in the dropdown menubar, maybe add some custom cell-type thereCode(javascript)
Code(CoffeeScript)
Code(babel)
Markdown
To implement that, there are some points
See this comment for an example.
As I know, a code block in Jupyter Notebook can use variable value from other block, how is this implemented in the nel?
I'm reading the code, consider how to embed nel into https://github.com/Jermolene/TiddlyWiki5 . Can you teach me a bit about the source code?
Moved from n-riesco/jp-babel#17
Examples of usage:
When a cell execution returns a promise; e.g.
getPromise();
this would be equivalent to
(function($$) {
$$.async();
getPromise().then(function(result) {
$$.sendResult(result);
}).catch(function(error) {
$$.sendError(error);
});
}($$);
Similarly with other output methods, e.g.:
$$.html(getPromise());
this would be equivalent to:
(function($$) {
$$.async();
getPromise().then(function(result) {
$$.html(result);
}).catch(function(error) {
$$.sendError(error);
});
}($$);
Moved discussion from n-riesco/ijavascript#117 (comment) :
I would solve this issue like this:
ContextifyScript.Script.runInThisContext();
with
ContextifyScript.Script.runInContext(currentContext);
If the code errors out, parse the error to check for this pattern:
SyntaxError: Identifier '*' has already been declared
if this pattern matches, create a new context to be used across the current session, and run the code again, any error created afterwards is propagated to the user.
function createContext() {
const sandbox = {
Buffer,
clearImmediate,
clearInterval,
clearTimeout,
setImmediate,
setInterval,
setTimeout,
console,
process,
// ...other ijavascript-y needed context
};
sandbox.global = sandbox;
return sandbox;
}
try {
ContextifyScript.Script.runInContext(currentContext);
} catch(e) {
if(DOUBLE_DECL_PATTERN.test(e.message)) {
currentContext = vm.createContext(createContext());
return ContextifyScript.Script.runInContext(currentContext);
}
throw e
}
I have not looked into the ijavascript code yet, but I am hoping to get some feedback on this before I do so.
See n-riesco/ijavascript#93 (comment)
@rgbkrk What would be the use case for giving the user access to display_id
?
IJavascript handles access to each cell by means of the object $$
. Each cell has its own $$
. And for this reason, there is no need to know the display_id
; we only need to know the $$
of each cell. Here's an example of how to use the $$
of multiple cells:
// In[1]
$$.async();
const $1 = global.$$;
const console1 = global.console;
console1.log("This goes to Out[1]");
$1.text("and this too");
// In[2]
$$.async();
const $2 = global.$$;
const console2 = global.console;
console2.log("This goes to Out[2]");
$2.text("and this too");
// In[3]
console1.log("This goes to Out[1]");
$1.text("and this too");
$1.done(); // close cell 1 output
console2.log("This goes to Out[2]");
$2.text("and this too");
$2.done(); // close cell 2 output
console.log("This goes to Out[3]");
"and this too";
In order to ensure functions exist when added as a magic as discussed in n-riesco/ijavascript#43, I need to resolve the function name using the inspect
function of the NEL session. Inspect uses callbacks, but transpile is synchronous.
Any objections to wrapping the transpile call in Promise.resolve() to make it indifferent as to whether the transpiler is synchronous or asynchronous? The try / catch
could be replaced with .then / .catch
to the same effect.
It doesn't look like _runNow
expects to be synchronous, so I don't think this would break anything else.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.