Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/graphnull/jupnode
Enable a Jupyter Notebook user to invoke Node.js commands.
https://github.com/graphnull/jupnode
js jupyter jupyter-notebook nodejs notebook tensorflowjs
Last synced: about 1 month ago
JSON representation
Enable a Jupyter Notebook user to invoke Node.js commands.
- Host: GitHub
- URL: https://github.com/graphnull/jupnode
- Owner: Graphnull
- License: mit
- Created: 2021-05-27T17:08:04.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2022-04-21T09:21:41.000Z (over 2 years ago)
- Last Synced: 2024-04-24T11:13:03.359Z (8 months ago)
- Topics: js, jupyter, jupyter-notebook, nodejs, notebook, tensorflowjs
- Language: JavaScript
- Homepage:
- Size: 2.4 MB
- Stars: 8
- Watchers: 1
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# jupnode
Jupnode lib for enable a Jupyter Notebook user to invoke Node.js commands.
![Screenshot: Notebook Hello Sample](images/img.png)
# Prerequisites
You need Node.js/npm installed. See the Node.js downloads page to find an installer for your platform.
# Using
After this cell other cells will run on node.js.
```python
!npm i jupnode
import jupnode
```Use %%py for use python in cell
```python
%%py
print(123)
print(54)
```You can use await in top level
```js
fs = require("fs");
await fs.promises.readFile("example.txt");
```Use var for global usage. Use let, const variables for local usage in cell
```js
var globalVar = 1;
let variableInCell = 2;
console.log(globalVar, variableInCell);
// 1 2
``````js
// 1
console.log(globalVar);
console.log(variableInCell);
// ReferenceError: variableInCell is not defined
```Use "sh" global function for system operations
```js
//install npm package
sh("npm i @tensorflow/tfjs-node");
//or
sh`npm i @tensorflow/tfjs-node`;//download file
let folder = "./";
sh`wget -nv http://pjreddie.com/media/files/VOCtrainval_06-Nov-2007.tar -P ${folder}/`;
```# Formatted output
Use "html" or "image" functions for formatted output
```js
//show html
html(`This is html
`);//show image base64
image("data:image/jpeg;base64, LzlqLzRBQ...");//show image url
image("https://kstatic.googleusercontent.com/...");
```# Profiling
Enable profiling for cell and save result as "profile.log" file after cell
```
await profiler('./profile.log');```
Load profile.log file into Chrome dev tools
![loadprofiler](images/loadprofiler.png)
Example profile.log
![profiler](images/profiler.png)