tj / co-prompt

sane terminal user-input for node.js using thunks / generators
192 stars 23 forks source link

Restricting possible user inputs #10

Open flauc opened 8 years ago

flauc commented 8 years ago

This isn't really an issue, just a question?

This is how i currently restrict the possible inputs

let a = (yield prompt("Create app? (Y/n) ")) || "Y";
while (!(/^([yn]|(yes)|(no))$/ig.test(a))) a= yield prompt("Create app? (Y/n) ");

Is there a better way of doing it?