Comments (5)
For the time being, here are two workarounds:
- Use
eval
:
eval(require("fs").readFileSync("f.js").toString());
- Use the flag
--ijs-startup-script=path
:
$ ijs --ijs-startup-script=f.js
I don't feel keen on messing with the Javascript grammar to support magics (IPython's %
or Node.js's .
). Up to now, the approach followed in IJavascript is to define a global object to communicate with the IJavascript kernel ($$mime$$
, $$async$$
, $$done$$()
, ...). We could define the global $$session$$
and provide methods such as $$session$$.load(filename)
and $$session$$.save(filename)
.
I realise that the number of IJavascript globals is increasing and I've been thinking for a while that, at some point in the future, we should define only one global. For example:
$$.async
$$.load(filename)
$$.save(filename)
$$.msg_id
$$.write(msg_id, data)
$$.writeToStdout(msg_id, data)
$$.writeToStderr(msg_id, data)
$$.close(msg_id)
$$.closeStdout(msg_id)
$$.closeStderr(msg_id)
$$.writeAsMime(msg_id, mime)
$$.writeAsHtml(msg_id, html)
$$.writeAsPng(msg_id, png)
from ijavascript.
I'm not a fan of any globals, though I hear ya. I'll rely on the eval
trick.
Most of my suggestions are going to be about mirroring node's repl as much as possible, while extending it with rich display.
from ijavascript.
Magics have their own kind of problems:
$ node
> .load f.js
> x = 2
2
> .load "f" + ".js"
Failed to load:"f" + ".js"
>
whereas globals blend nicely with Javascript because they are Javascript:
eval(require("fs").readFileSync("f" + ".js").toString());
from ijavascript.
They definitely do. I even despise them being within IPython as it breaks compatibility with plain Python scripts.
What I want to make sure of is that if a node user was used to being able to do something at the command line and they start using it in a notebook (or console), that we don't break their normal flow. That's my two cents. If it belongs in a different kernel, that's ok. I'm just going to raise things as I use ijavascript in my daily flow and submit PRs when it seems like you're happy with the ideas.
from ijavascript.
I will leave the issue open. I would like to provide this functionality. I'm keener to use a global, but there are more possibilities.
from ijavascript.
Related Issues (20)
- Install ijavascript in Windows without Visual Studio HOT 9
- Give a documented dependency install on Linux (ubuntu) HOT 13
- Can't output separate charts HOT 9
- [requirejs] Unable to load library with Jupyter Notebook HOT 5
- Thoughts on how to run iJavaScript on mybinder? HOT 4
- No output when using %%javascript magic HOT 2
- Unable to run in Ubuntu WSL2 Visual Studio Code (`spawn ijskernel ENOENT`) HOT 2
- import / require statements break vscode code analysis HOT 2
- IJavaScript stopped working after upgrading the major version of node.js HOT 2
- Jupyter notebook (and Jupyter lab too) gives error when loading d3 library HOT 2
- Updated NVM version, got error "no such file or directory" ".../bin/node" HOT 2
- Add a rebuild command
- jupyterlite Support
- Java script kernel stops working in Jupyter Lab HOT 3
- Is it still maintained HOT 4
- Cant install ijavascript (npm ERR! enoent spawn C:\Windows\system32\cmd.exe ENOENT) HOT 2
- ijsinstall: not working due to wrong use of ipython --user HOT 5
- SyntaxError: Cannot use import statement outside a module HOT 2
- install failed due to zeromq (Node v21) HOT 1
- npm install fails on macos Sonoma 14.4.1 HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ijavascript.