{"id":20551489,"url":"https://github.com/generate/to-choices","last_synced_at":"2025-06-20T18:39:39.384Z","repository":{"id":65412415,"uuid":"47079776","full_name":"generate/to-choices","owner":"generate","description":"Generate an inquirer choices question from an array.","archived":false,"fork":false,"pushed_at":"2016-02-27T20:51:40.000Z","size":14,"stargazers_count":5,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-14T11:44:54.968Z","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":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/generate.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":"2015-11-29T20:49:58.000Z","updated_at":"2016-11-20T23:53:35.000Z","dependencies_parsed_at":"2023-01-22T07:55:23.796Z","dependency_job_id":null,"html_url":"https://github.com/generate/to-choices","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/generate/to-choices","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/generate%2Fto-choices","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/generate%2Fto-choices/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/generate%2Fto-choices/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/generate%2Fto-choices/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/generate","download_url":"https://codeload.github.com/generate/to-choices/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/generate%2Fto-choices/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":260999354,"owners_count":23095309,"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-11-16T02:31:26.834Z","updated_at":"2025-06-20T18:39:34.351Z","avatar_url":"https://github.com/generate.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# to-choices [![NPM version](https://img.shields.io/npm/v/to-choices.svg)](https://www.npmjs.com/package/to-choices) [![Build Status](https://img.shields.io/travis/generate/to-choices.svg)](https://travis-ci.org/generate/to-choices)\n\n\u003e Easily create a normalized inquirer choices question. Supports all of the `choices` question types: checkbox, list, rawlist, expand\n\n## Install\n\nInstall with [npm](https://www.npmjs.com/):\n\n```sh\n$ npm install to-choices --save\n```\n\n## Heads up!\n\n**Breaking changes made in v02.0!**\n\nThe main export now returns a function that takes an options object and, when called, returns the `toChoices` function to be usef for creating the question object.\n\n## Usage\n\n```js\nvar toChoices = require('to-choices')([options]);\n\nvar question = toChoices('foo', ['a', 'b', 'c']);\nconsole.log(question);\n```\n\nThe default `type` is `checkbox`, so the above code results in:\n\n```js\n{ type: 'checkbox',\n  name: 'foo',\n  message: 'foo',\n  choices:\n   [ { name: 'all', value: ['a', 'b', 'c'] },\n     { type: 'separator', line: '\\u001b[90m————\\u001b[39m' },\n     { name: 'a' },\n     { name: 'b' },\n     { name: 'c' } ] }\n```\n\n## Supported question types\n\nIn addition to `checkbox`, the following types are also supported:\n\n* `expand`\n* `list`\n* `rawlist`\n\nSignature and all params are the same. Just pass the `type` to the main export.\n\n**Example**\n\nCreate a `list` question:\n\n```js\nvar toQuestions = require('to-choices')({type: 'list'});\nvar question = toChoices('favorite color?', [\n  'red',\n  'blue',\n  'green'\n]);\nconsole.log(question);\n```\n\nResults in:\n\n```js\n{ type: 'list',\n  choices: [ 'red', 'blue', 'green' ],\n  name: 'favorite color',\n  message: 'favorite color' }\n```\n\nSee the [inquirer2](https://github.com/jonschlinkert/inquirer2) documentation for more details about question objects and supported properties.\n\n## Related projects\n\n* [answer-store](https://www.npmjs.com/package/answer-store): Store answers to user prompts, based on locale and/or current working directory. | [homepage](https://github.com/jonschlinkert/answer-store)\n* [question-store](https://www.npmjs.com/package/question-store): Ask questions, persist the answers. Basic support for i18n and storing answers based on current… [more](https://www.npmjs.com/package/question-store) | [homepage](https://github.com/jonschlinkert/question-store)\n\n## Contributing\n\nPull requests and stars are always welcome. For bugs and feature requests, [please create an issue](https://github.com/jonschlinkert/to-choices/issues/new).\n\n## Building docs\n\nGenerate readme and API documentation with [verb](https://github.com/verbose/verb):\n\n```sh\n$ npm install verb \u0026\u0026 npm run docs\n```\n\nOr, if [verb](https://github.com/verbose/verb) is installed globally:\n\n```sh\n$ verb\n```\n\n## Running tests\n\nInstall dev dependencies:\n\n```sh\n$ npm install -d \u0026\u0026 npm test\n```\n\n## Author\n\n**Jon Schlinkert**\n\n* [github/jonschlinkert](https://github.com/jonschlinkert)\n* [twitter/jonschlinkert](http://twitter.com/jonschlinkert)\n\n## License\n\nCopyright © 2016 [Jon Schlinkert](https://github.com/jonschlinkert)\nReleased under the [MIT license](https://github.com/generate/to-choices/blob/master/LICENSE).\n\n***\n\n_This file was generated by [verb](https://github.com/verbose/verb), v0.9.0, on February 27, 2016._","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgenerate%2Fto-choices","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgenerate%2Fto-choices","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgenerate%2Fto-choices/lists"}