{"id":16556297,"url":"https://github.com/miraclx/ninjaquery","last_synced_at":"2026-05-11T15:06:12.229Z","repository":{"id":57311110,"uuid":"190463285","full_name":"miraclx/ninjaQuery","owner":"miraclx","description":"Middlelayer for Inquirer.js to allow prompting even when output is piped","archived":false,"fork":false,"pushed_at":"2019-08-06T16:15:57.000Z","size":57,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-28T09:17:42.765Z","etag":null,"topics":["inquirer","ninjaquery","nodejs","persistent-pipe","pipe","prompt","query","stdin","stdout","tty"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/miraclx.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-06-05T20:25:19.000Z","updated_at":"2019-08-06T16:16:00.000Z","dependencies_parsed_at":"2022-09-07T10:20:09.295Z","dependency_job_id":null,"html_url":"https://github.com/miraclx/ninjaQuery","commit_stats":null,"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/miraclx%2FninjaQuery","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/miraclx%2FninjaQuery/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/miraclx%2FninjaQuery/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/miraclx%2FninjaQuery/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/miraclx","download_url":"https://codeload.github.com/miraclx/ninjaQuery/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241928955,"owners_count":20043908,"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":["inquirer","ninjaquery","nodejs","persistent-pipe","pipe","prompt","query","stdin","stdout","tty"],"created_at":"2024-10-11T20:04:06.422Z","updated_at":"2026-05-11T15:06:07.176Z","avatar_url":"https://github.com/miraclx.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# NinjaQuery\n\n\u003e Middlelayer for Inquirer.js to allow prompting even when output is piped\n\n[![NPM Version][npm-image]][npm-url]\n[![NPM Downloads][downloads-image]][downloads-url]\n\n[![NPM][npm-image-url]][npm-url]\n\n## Installing\n\nVia [NPM][npm]:\n\n``` bash\nnpm install ninja_query\n```\n\n## Usage\n\n``` javascript\n// Node CommonJS\nconst ninjaQuery = require('ninja_query');\n// Or Node ES6\nimport ninjaQuery from 'ninja_query';\n```\n\n## Examples\n\n``` javascript\n// Use ninjaQuery just like you use \nninjaQuery({\n  name: \"name\",\n  message: \"What is your name?\"\n}).then(({name}) =\u003e console.log(`Hello, ${name}`))\n```\n\n### API\n\n#### \u003ca id='ninjaquery'\u003e\u003c/a\u003e ninjaQuery(questions)\n\n* `quetions`: \u0026lt;[Question](#question) | [Question](#question)[]\u0026gt;\n* Returns: \u0026lt;[Promise]\u0026gt;\n\nLaunch the prompt interface (inquiry session)\n\n#### \u003ca id='ninjaquery_extend'\u003e\u003c/a\u003e ninjaQuery.extend(templateID[, question])\n\n* `templateID`: \u0026lt;[string]\u0026gt;\n* `quetion`: \u0026lt;[Question](#question) | [Question](#question)[]\u0026gt;\n* Returns: \u0026lt;[Question](#question)\u0026gt;\n\nMerge the `templateID`'s [default Question](#defaultquestions) with the specified `question` object.\n\n#### \u003ca id='ninjaquery_password'\u003e\u003c/a\u003e ninjaQuery.password(question[, options])\n\n* `question`: \u0026lt;[Question](#question)\u0026gt; Question block to be used\n* `options`: \u0026lt;[Object]\u0026gt; Password options\n  - `confirm`: \u0026lt;[string]\u0026gt; Whether or not to request a re-enter for confirmation of input. **Default**: `false`\n  - `confirmMessage`: \u0026lt;[string]\u0026gt; Message to print on the re-enter prompt. **Default**: `'Re enter password ?'`\n  - `unmatchMessage`: \u0026lt;[string]\u0026gt; Message to print when passwords don't match. **Default**: `'[!] Password mismatch'`\n* Returns: \u0026lt;[Promise]\u0026gt;\n\nConstruct a password prompt that inherits from [DefaultQuestions.password](#defaultquestions_password) and can request a password re-entry for confirmation.\n\n#### \u003ca id='defaults'\u003e\u003c/a\u003e ninjaQuery.defaults: [DefaultQuestions](#defaultquestions)\n\n#### \u003ca id='question'\u003e\u003c/a\u003e Question\n\nA question object is a hash containing question related values:\n\n- `type`: \u0026lt;[string]\u0026gt; Type of the prompt.\n- `name`: \u0026lt;[string]\u0026gt; The name to use when storing the answer in the answers hash. If the name contains periods, it will define a path in the answers hash.\n- `message`: \u0026lt;[string]| (`rootObject`: [object]) =\u003e [string] \u0026gt; The question to print. If defined as a function, the first parameter will be the current inquirer session answers. Defaults to the value of name (followed by a colon).\n- `default`: \u0026lt;[string]|[number]|[boolean]|[array]|[function]\u0026gt; Default value(s) to use if nothing is entered, or a function that returns the default value(s). If defined as a function, the first parameter will be the current inquirer session answers.\n- `choices`: \u0026lt;[array]| (`rootObject`: [object]) =\u003e [array] \u0026gt; Choices array or a function returning a choices array. If defined as a function, the first parameter will be the current inquirer session answers. Array values can be simple numbers, strings, or objects containing a name (to display in list), a value (to save in the answers hash) and a short (to display after selection) properties. The choices array can also contain a Separator.\n- `validate`: \u0026lt; (`input`: [string], `hash`: [object]) =\u003e [boolean] \u0026gt; Receive the user input and answers hash. Should return true if the value is valid, and an error message (String) otherwise. If false is returned, a default error message is provided.\n- `filter`: \u0026lt; `input` =\u003e [string] \u0026gt; Receive the user input and return the filtered value to be used inside the program. The value returned will be added to the Answers hash.\n- `transformer`: \u0026lt; (`input`: [string], `hash`: [object], `flags`: [object]) =\u003e [string] \u0026gt; Receive the user input, answers hash and option flags, and return a transformed value to display to the user. The transformation only impacts what is shown while editing. It does not modify the answers hash.\n- `when`: \u0026lt; `hash` =\u003e [boolean] \u0026gt; Receive the current user answers hash and should return true or false depending on whether or not this question should be asked. The value can also be a simple boolean.\n- `pageSize`: \u0026lt;[number]\u0026gt; Change the number of lines that will be rendered when using list, rawList, expand or checkbox.\n- `prefix`: \u0026lt;[string]\u0026gt; Change the default prefix message.\n- `suffix`: \u0026lt;[string]\u0026gt; Change the default suffix message.\n  \n#### \u003ca id='defaultquestions'\u003e\u003c/a\u003e DefaultQuestions\n\nDefault templates for [Question](#question)\n\n\u003ca id=\"defaultquestions_password\"\u003e\u003c/a\u003e - `password`\n\n  name | type | message | validate\n  ---- | ---- | ------- | --------\n  `'password'` | `'password'` | `'Please enter a password :'` | [function]\n\n\t- `validate`: Password must be 4 characters or more\n      - **else** `'Password should contain at least 4 characters'`\n\n- `confirm`\n\n  name | type | message\n  ---- | ---- | -------\n  `'confirm'` | `'confirm'` | `'Are you sure?'`\n\n- `name`\n\n  name | type | message | filter | transformer | validate\n  ---- | ---- | ------- | ------ | ----------- | --------\n  `'name'` | `'input'` | `'Enter full name :'` | [function] | [function] | [function]\n\n\t- `filter`: Autocapitalise first character\n\t- `validate`: A least one character must be present\n\t- `transform`: Autocapitalise first character, colorise when [Enter] is pressed\n\n- `username`\n\n  name | type | message | validate\n  ---- | ---- | ------- | --------\n  `'username'` | `'input'` | `'Enter user name :'` | [function]\n\n  - `validate`: A least one character must be present\n\n- `email`\n\n  name | type | message | transformer | validate\n  ---- | ---- | ------- | ----------- | --------\n  `'email'` | `'input'` | `'Enter your email :'` | [function] | [function]\n\n\t- `validate`: Email must be valid\n      - **else** `'Email invalid'`\n\t- `transform`: Colorise email once email is valid\n\n- `dateofbirth`\n\n  name | type | message | filter | transformer | validate | suffix \n  ---- | ---- | ------- | ------ | ----------- | -------- | ------\n  `'dateofbirth'` | `'input'` | `'Date Of Birth '` | [function] | [function] | [function] | `'[ddmmyy]:'`\n\n\t- `filter`: Insert separator `'/'` to date in answers\n\t- `validate`: Must be a valid date in the format 'dd/mm/yy'\n      - **else** `'Date of birth should match the format [dd/mm/yy]'`\n\t- `transform`: Insert separator `'/'` to date on input\n  \n## More Examples\n\nCheck out some examples in the [`examples`](examples) folder\n\n``` javascript\n$ node examples/form.js\n$ node examples/login.js\n$ node examples/password.js\n```\n\n## Development\n\n### Building\n\nFeel free to clone, use in adherance to the [license](#license) and perhaps send pull requests\n\n``` bash\ngit clone https://github.com/miraclx/ninjaQuery.git\ncd ninjaquery\nnpm install\n# hack on code\nnpm run build\n```\n\n## License\n\n[Apache 2.0][license] © **Miraculous Owonubi** ([@miraclx][author-url]) \u0026lt;omiraculous@gmail.com\u0026gt;\n\n[npm]:  https://github.com/npm/cli 'The Node Package Manager'\n[license]:  LICENSE 'Apache 2.0 License'\n[author-url]: https://github.com/miraclx\n\n[npm-url]: https://npmjs.org/package/ninja_query\n[npm-image]: https://badgen.net/npm/node/ninja_query\n[npm-image-url]: https://nodei.co/npm/ninja_query.png?stars\u0026downloads\n[downloads-url]: https://npmjs.org/package/ninja_query\n[downloads-image]: https://badgen.net/npm/dm/ninja_query\n\n[number]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Number_type\n[array]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array\n[object]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object\n[regexp]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp\n[string]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type\n[boolean]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Boolean_type\n[function]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function\n[promise]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmiraclx%2Fninjaquery","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmiraclx%2Fninjaquery","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmiraclx%2Fninjaquery/lists"}