Closed AlvaroBernalG closed 7 years ago
@AlvaroBernalG Could you add an example showing how the Node.js REPL handles this? (Include your Node.js version)
v8.1.2 Same behaviour.
The CoffeeScript REPL uses the Node.js REPL. So if the Node.js REPL can't handle this, CoffeeScript can't either.
Wouldn't be possible to wrap the user input into 'async function main(){}' and then send it to the Node.js REPL?
So if you have something like this:
coffeescript> sleep = (ms)=> new Promise((resolve, reject) => setTimeout(resolve,ms))
coffeescript> await sleep(2000)
It would get transpiled into :
async function main(){
var sleep;
sleep = (ms)=> new Promise((resolve, reject) => setTimeout(resolve,ms))
console.log(await sleep(2000))
}
do -> await sleep(2000)
@GeoffreyBooth @lydell Thank you for your time :) .
P.S: Coffeescript 2 is looking great so far. I will definitely be using it in one of my next projects.
Thanks!
Hello good people of coffeescript:
Currently, the way I can test how a library that heavily rely on promises works on the REPL is as follow:
I can also define a function, but doing that on a REPL is awkward. I would rather create a file and set up an environment that auto run my script on save instead.
It would great if I could just take advantage of the new async/await features of coffeescript 2.0 and do this instead:
Which adjust perfectly with the philosophy of a REPL which is providing you with an environment to quickly and easily test and prototype stuff out.