{"id":15856872,"url":"https://github.com/ebenjs/interrogation","last_synced_at":"2025-04-01T19:27:06.290Z","repository":{"id":47575780,"uuid":"397767263","full_name":"ebenjs/interrogation","owner":"ebenjs","description":"Tiny library for question / answer","archived":false,"fork":false,"pushed_at":"2021-08-23T17:32:40.000Z","size":79,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-22T15:03:16.020Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ebenjs.png","metadata":{"files":{"readme":"readme.md","changelog":"CHANGELOG.md","contributing":null,"funding":".github/FUNDING.yml","license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null},"funding":{"github":null,"patreon":"ebenjs","open_collective":null,"ko_fi":null,"tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"otechie":null,"custom":null}},"created_at":"2021-08-19T00:13:59.000Z","updated_at":"2021-08-23T17:31:14.000Z","dependencies_parsed_at":"2022-07-22T06:17:54.779Z","dependency_job_id":null,"html_url":"https://github.com/ebenjs/interrogation","commit_stats":null,"previous_names":["ebenezer10/interrogation"],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ebenjs%2Finterrogation","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ebenjs%2Finterrogation/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ebenjs%2Finterrogation/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ebenjs%2Finterrogation/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ebenjs","download_url":"https://codeload.github.com/ebenjs/interrogation/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246699043,"owners_count":20819665,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-05T20:04:26.208Z","updated_at":"2025-04-01T19:27:06.264Z","avatar_url":"https://github.com/ebenjs.png","language":"JavaScript","funding_links":["https://patreon.com/ebenjs","https://www.buymeacoffee.com/ebenjs"],"categories":[],"sub_categories":[],"readme":"# Interrogation\nA tiny library that allows you to ask a series of questions to the user in the console.\n\n## Features\n- Ask question\n- Ask MCQ questions\n- Get response from user\n- Supports coloring\n\n## How it works\n\n### Install\n```shell\nnpm install interrogation\n```\n### Import the library\n\n```javascript\nconst interrogation = require('interrogation')\n```\n### Ask a question\nAn array of questions is required for the use of the function ```getAnswersFor()```.\n\n``` javascript\nconst interrogation = require('interrogation')\n\ninterrogation.getAnswersFor(['question1? ', 'question2? ']).then((value) =\u003e {\n    console.log(value);\n});\n```\nTo ask a MCQ (multiple choice question), wrap your question and it's possible choices in an array and pass it to the ```getAnswersFor()``` function.\n\n```javascript\ninterrogation.getAnswersFor(['question1? ', 'question2? ', ['question3', ['choice1', 'choice2', 'choice3']]]).then((value) =\u003e {\n  console.log(value);\n});\n```\n\n### Get response\nThe response of an interrogation is an array of objects structured like this :\n\n```javascript\n[\n  { question: 'Question1 ', response: 'Response1' },\n  { question: 'Question2 ', response: 'Response2' },\n  { question: 'Question3', response: '2' } // choice 2\n]\n```\n\n### Version ^0.1.0 : Create a file of questions\nYou can now create a json file of questions, encode these questions or decode them.\n\n#### Create a question file\nJust create a json file with questions structured like below:\n```json\n[\n  {\n    \"type\": \"simple-question\",\n    \"label\": \"Question 1\",\n    \"format\": \"string\"\n  },\n  {\n    \"type\": \"simple-question\",\n    \"label\": \"Question 2\",\n    \"format\": \"string\"\n  },\n  {\n    \"type\": \"one-choice-mcq\",\n    \"label\": \"Question 3\",\n    \"choices\": [\"Choice 1\", \"Choice 2\", \"Choice 3\"]\n  },\n  {\n    \"type\": \"simple-question\",\n    \"label\": \"Question 4\",\n    \"format\": \"number\"\n  }\n]\n```\n#### Encode a question file\nYou can encode questions by calling the ```encodeQuestions()``` function.\n```javascript\nconsole.log(interrogation.encodeQuestions('json-question.json'));\n```\nThe output is a base64 string.\n##### Output\n```\nWwogIHsKICAgICJ0eXBlIjogInNpbXBsZS1xdWVzdGlvbiIsCiAgICAibGFiZWwiOiAiUXVlc3Rpb24gMSIsCiAgICAiZm9ybWF0IjogInN0cmluZyIKICB9LAogIHsKICAgICJ0eXBlIjogInNpbXBsZS1xdWVzdGlvbiIsCiAgICAibGFiZWwiOiAiUXVlc3Rpb24gMiIsCiAgICAiZm9ybWF0IjogInN0cmluZyIKICB9LAogIHsKICAgICJ0eXBlIjogIm9uZS1jaG9pY2UtbWNxIiwKICAgICJsYWJlbCI6ICJRdWVzdGlvbiAzIiwKICAgICJjaG9pY2VzIjogWyJDaG9pY2UgMSIsICJDaG9pY2UgMiIsICJDaG9pY2UgMyJdCiAgfSwKICB7CiAgICAidHlwZSI6ICJzaW1wbGUtcXVlc3Rpb24iLAogICAgImxhYmVsIjogIlF1ZXN0aW9uIDQiLAogICAgImZvcm1hdCI6ICJudW1iZXIiCiAgfQpd\n```\nA new file (```question.int```) containing the output is also generated. You can then send this file to anyone interrested in answering your questions. This can be very useful for an investigation or a survey.\n\n#### Decode question file\nOn the other side, the ```question.int``` file can be decoded by calling the ```decodeQuestions()``` function.\n```javascript\nconsole.log(interrogation.decodeQuestions('question.int'));\n```\n##### Output\n```json\n[\n  {\n    \"type\": \"simple-question\",\n    \"label\": \"Question 1\",\n    \"format\": \"string\"\n  },\n  {\n    \"type\": \"simple-question\",\n    \"label\": \"Question 2\",\n    \"format\": \"string\"\n  },\n  {\n    \"type\": \"one-choice-mcq\",\n    \"label\": \"Question 3\",\n    \"choices\": [\"Choice 1\", \"Choice 2\", \"Choice 3\"]\n  },\n  {\n    \"type\": \"simple-question\",\n    \"label\": \"Question 4\",\n    \"format\": \"number\"\n  }\n]\n```\nYou can also get answers for encoded file directly by calling the ```getAnswersForJson()``` function.\n```javascript\ninterrogation.getAnswersForJson('question.int').then((value) =\u003e {\n  console.log(value);\n});\n```\n##### Output\n```javascript\n[\n  { question: 'Question 1', response: 'Response 1' },\n  { question: 'Question 2', response: 'Response 2' },\n  { question: 'Question 3', response: '3' }, // Choice 3\n  { question: 'Question 4', response: 'Response 4' }\n]\n```\n### Future updates\n- Support of multiple choices.\n- Send encoded files by e-mail.\n- Develop a client to answer question (for non-developers).\n\n### Buy me a coffee\n\u003ca href=\"https://www.buymeacoffee.com/ebenjs\" target=\"_blank\"\u003e\u003cimg src=\"https://cdn.buymeacoffee.com/buttons/v2/default-yellow.png\" alt=\"Buy Me A Coffee\" style=\"height: 30px !important;width: 117px !important;\" \u003e\u003c/a\u003e","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Febenjs%2Finterrogation","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Febenjs%2Finterrogation","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Febenjs%2Finterrogation/lists"}