typescript-notebook icon indicating copy to clipboard operation
typescript-notebook copied to clipboard

Readline (user input) usage

Open jaeggerr opened this issue 4 years ago • 1 comments

Hello!

First of all, I'd like to thank you a lot for this awesome project. I've been waiting for years for a tool like Jupyter in Visual Studio Code for Node development.

Could you provide an example of how to get the user input? I tried different ways to use readline without any success.

Other question. Is there a way to input a file? I was thinking of using HTML but could not find a way to communicate between the JavaScript from HTML cells and the the JavasScript from the notebook.

jaeggerr avatar Nov 19 '21 11:11 jaeggerr

Hi, I ran this from https://node.readthedocs.io/en/latest/api/readline/ and it works. The prompt input box appears at the top of the IDE as a dropdown.

var readline = require('readline');

var rl = readline.createInterface({ input: process.stdin, output: process.stdout });

rl.question("What do you think of node.js? ", function(answer) { // TODO: Log the answer in a database console.log("Thank you for your valuable feedback:", answer);

rl.close(); });

andrewtacon avatar Dec 18 '21 06:12 andrewtacon