heapwolf / prompt-sync

a synchronous prompt for node.js
MIT License
211 stars 42 forks source link

Sample code fails if used within a class method, presumably because 'prompt' is a reserved word #38

Closed gwtuser closed 5 years ago

gwtuser commented 5 years ago

When I install and attempt to use prompt-sync, the basic sample code works if run all by itself, but if

var prompt = require('prompt-sync')();

is put at the top of a JavaScript class file (global scope) and then

var n = prompt('How many more times? ');

Is put inside a class method defined in that file (where it should have access to the variable), it crashes claiming that 'prompt' isn't defined. If I change the definition to use 'prompt2', things work. So you should probably avoid using 'prompt' as a variable as it's a JS reserved word.

Splaktar commented 5 years ago

I don't see prompt listed as a reserved word on MDN or here.

davidmarkclements commented 5 years ago

yeah this seems more like a bug in your code - but prompt is definitely not a reserved word.

There is a global prompt in the browser, but this package is for Node.js.

Closing as this is not an issue with this module.