DonJayamanne/typescript-notebook

Readline (user input) usage

Opened this issue · 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.

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();
});