{"_id":"prompt-async","_rev":"2-6a8373ebbb3d22647ce063c509b23ddb","name":"prompt-async","description":"The enhanced prompt module that enables you to `await` its methods.","dist-tags":{"latest":"0.9.9"},"versions":{"0.9.9":{"name":"prompt-async","version":"0.9.9","description":"The enhanced prompt module that enables you to `await` its methods.","author":{"name":"K.","email":"wlzla000@naver.com","url":"https://github.com/wlzla000/prompt-async"},"license":"MIT","main":"prompt-async.js","engines":{"node":">=5.12.0"},"repository":{"type":"git","url":"git+https://github.com/wlzla000/prompt-async.git"},"bugs":{"url":"https://github.com/wlzla000/prompt-async/issues"},"homepage":"https://github.com/wlzla000/prompt-async#readme","scripts":{"test":"echo \"Error: no test specified\" && exit 1"},"keywords":["prompt","async","await","async-await","Promise","Promisify"],"dependencies":{"prompt":"^1.0.0"},"_id":"prompt-async@0.9.9","_npmVersion":"5.4.2","_nodeVersion":"8.7.0","_npmUser":{"name":"wlzla000","email":"wlzla000@naver.com"},"dist":{"integrity":"sha512-XHpcP55ME/MRHvvKTGYSayMMpWY7M2dEx5g6WdfHabkO4+BrJIWeZh4+qJG4lRgebr5ovT+Cnv98qfmXqQ3RXA==","shasum":"6fb90053480eec4d06368d6e7fa434736b61193b","tarball":"https://registry.npmjs.org/prompt-async/-/prompt-async-0.9.9.tgz","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIF0NuXDVAGSs0HAOVP7ss+jBCceds0n/TKzuGVDjJRozAiEAhnuSlskPmGTjBW9UOiFCRGTbn0W4ds1aS9H3n/3pgc0="}]},"maintainers":[{"name":"wlzla000","email":"wlzla000@naver.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/prompt-async-0.9.9.tgz_1508740394643_0.7361353416927159"}}},"readme":"# [prompt-async](https://www.npmjs.com/package/prompt-async)\n\nThe **enhanced** [`prompt`](https://www.npmjs.com/package/prompt) module that enables you to [**`await`** its methods](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/async_function).\n\n## Example <sup>[Try it now!](https://runkit.com/npm/prompt-async)</sup>\n\n##### With [`prompt-async`](https://www.npmjs.com/package/prompt-async)\n\n```javascript\nconst prompt = require(\"prompt-async\");\n\nasync function example_async() // Available only with `prompt-async`!\n{\n\t// Start the prompt.\n\tprompt.start();\n\n\t// Get two properties from the user: the `username` and `email`.\n\tconst {username, email} = await prompt.get([\"username\", \"email\"]);\n\t// Get two properties from the user: the `password` and `food`.\n\tconst {password, food} = await prompt.get([\"password\", \"food\"]);\n\n\t// Log the results.\n\tconsole.log(\"Command-line input received: \");\n\tconsole.log(`  username: ${username},`);\n\tconsole.log(`  password: ${password},`);\n\tconsole.log(`  email: ${email},`);\n\tconsole.log(`  food: ${food}.`);\n}\n\nasync function error_handling_async()\n{\n\ttry\n\t{\n\t\tawait example_async();\n\t}\n\tcatch(error)\n\t{\n\t\tconsole.error(\"An error occurred: \", error);\n\t}\n}\n\nerror_handling_async();\n```\n\n##### The obsolete way <sub>(causes a [_callback hell_](http://callbackhell.com))</sub>\n\n```javascript\nconst prompt = require(\"prompt-async\");\n\nfunction example() // Still supports the obsolete way.\n{\n\t// Start the prompt.\n\tprompt.start();\n\n\t// Get two properties from the user: the `username` and `email`.\n\tprompt.get([\"username\", \"email\"], (error, result1) => {\n\t\tif(error)\n\t\t{\n\t\t\tthrow Error(error);\n\t\t}\n\n\t\t// Get two properties from the user: the `password` and `food`.\n\t\tprompt.get([\"password\", \"food\"], (error, result2) => {\n\t\t\tif(error)\n\t\t\t{\n\t\t\t\tthrow Error(error);\n\t\t\t}\n\n\t\t\t// Log the results.\n\t\t\tconsole.log(\"Command-line input received: \");\n\t\t\tconsole.log(`  username: ${result1.username},`);\n\t\t\tconsole.log(`  password: ${result2.password},`);\n\t\t\tconsole.log(`  email: ${result1.email},`);\n\t\t\tconsole.log(`  food: ${result2.food}.`);\n\t\t});\n\t});\n}\n\nfunction error_handling()\n{\n\ttry\n\t{\n\t\texample();\n\t}\n\tcatch(error)\n\t{\n\t\tconsole.error(\"An error occurred: \", error);\n\t}\n}\n\nerror_handling();\n```\n\n\n## Frequently answered questions\n\n### I've been working with [`prompt`](https://www.npmjs.com/package/prompt). Do I have to modify the existing code to use this?\n\n**The only thing you have to do is to replace `require(\"prompt\")` to `require(\"prompt-async\")`.**\nAs you can see above, it has backward-compatibility, so it would work well with your `prompt` code.\nHowever, please be aware that your `prompt` code pattern is discouraged, and try to use _`async`-`await`_ pattern.\n\n\n## Any bugs, suggestions, or questions?\n\nIf you found a bug on it, or if you want to suggest something to improve it, or if you have a question,\nplease [leave an issue on the _GitHub_ repository](https://github.com/wlzla000/prompt-async/issues) or send an e-mail to me: `wlzla000@naver.com`.\n\n**Feel free to contribute!**\n\nThank you.\n\n\n## Licensed under\n\n[the MIT license](https://github.com/wlzla000/prompt-async/blob/master/LICENSE).\n","maintainers":[{"name":"wlzla000","email":"wlzla000@naver.com"}],"time":{"modified":"2022-05-13T12:56:00.384Z","created":"2017-10-23T06:33:14.735Z","0.9.9":"2017-10-23T06:33:14.735Z"},"homepage":"https://github.com/wlzla000/prompt-async#readme","keywords":["prompt","async","await","async-await","Promise","Promisify"],"repository":{"type":"git","url":"git+https://github.com/wlzla000/prompt-async.git"},"author":{"name":"K.","email":"wlzla000@naver.com","url":"https://github.com/wlzla000/prompt-async"},"bugs":{"url":"https://github.com/wlzla000/prompt-async/issues"},"license":"MIT","readmeFilename":"README.md","users":{"wlzla000":true}}