Skip to content

Commit

Permalink
binding
Browse files Browse the repository at this point in the history
  • Loading branch information
DerThorsten committed Jan 19, 2024
1 parent a27d3e7 commit 0fbf1da
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 26 deletions.
22 changes: 6 additions & 16 deletions notebooks/xeus-javascript.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"<center>\n",
" <h1>javascript kernel based on xeus</h1>\n",
"</center>"
"# javascript kernel based on xeus\n"
]
},
{
Expand Down Expand Up @@ -64,28 +62,20 @@
},
"outputs": [],
"source": [
"await new Promise(r => setTimeout(r, 2000));"
"const sleep = ms => new Promise(r => setTimeout(r, ms));\n",
"console.log(\"pre sleep\")\n",
"await sleep(1000);\n",
"console.log(\"post sleep\")"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# auto completion\n",
"press tab"
"press tab (ijs.display.svg or ijs.display.html are some of many possible completions)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"vscode": {
"languageId": "plaintext"
}
},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
Expand Down
20 changes: 11 additions & 9 deletions src/pre.js
Original file line number Diff line number Diff line change
@@ -1,22 +1,24 @@
Module["_make_async_from_code"] = function (code) {







let async_function = Function(`
const afunc = async function(){
function __storeVars(target) {
return new Proxy(target, {
has(target, prop) { return true; },
get(target, prop) { return (prop in target ? target : globalThis)[prop]; }
get(target, prop) {
if(prop in target){
return target[prop];
}
else{
if (typeof globalThis[prop] === 'function') {
return globalThis[prop].bind(globalThis);
}
return globalThis[prop];
}
}
});
}
let __stored_vars = {};
with(__storeVars(__stored_vars)) {
Expand Down
2 changes: 1 addition & 1 deletion src/xinterpreter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ namespace xeus_javascript

interpreter::interpreter()
{
std::cout<<"V37"<<std::endl;
std::cout<<"V44"<<std::endl;
xeus::register_interpreter(this);
}

Expand Down

0 comments on commit 0fbf1da

Please sign in to comment.