{"name":"ask-once","description":"Only ask a question one time and store the answer.","version":"0.2.2","homepage":"https://github.com/doowb/ask-once","author":{"name":"Brian Woodward","url":"https://github.com/doowb"},"repository":{"type":"git","url":"git+https://github.com/doowb/ask-once.git"},"bugs":{"url":"https://github.com/doowb/ask-once/issues"},"license":"MIT","files":["index.js"],"main":"index.js","engines":{"node":">=0.10.0"},"scripts":{"test":"mocha"},"devDependencies":{"data-store":"^0.8.1","inquirer":"^0.9.0","minimist":"^1.1.3","mocha":"*","question-cache":"^0.2.1"},"verb":{"related":{"list":["question-cache","question-helper","inquirer","data-store"]}},"dependencies":{"get-value":"^1.1.5"},"gitHead":"017fbfec83207f654a09fbdaf88171456f649170","_id":"ask-once@0.2.2","_shasum":"b0ac937700f649354e8ce1ff34837f7a1634f08a","_from":".","_npmVersion":"2.13.3","_nodeVersion":"0.12.0","_npmUser":{"name":"doowb","email":"brian.woodward@gmail.com"},"dist":{"shasum":"b0ac937700f649354e8ce1ff34837f7a1634f08a","tarball":"http://registry-npm.ywwl.com/ask-once/download/ask-once-0.2.2.tgz","integrity":"sha512-bTF+a+nCOqbv9oo/HVGcDVWgzLgztDdVtvh0xwwOqnF7wqat7Z2Wax3WJ4Atza1CHz49xKWuDhKbyiRVZu5+Hg==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIEo0IemXXqJ/4Z0aShyfN82+8Rv7/8t84y9/1aJNEyafAiBIn+iE1SUszn+QSbDmFWVCmQzjMr7ghsMzdaDK1TZ1xQ=="}],"size":3505,"noattachment":false,"key":"/ask-once/-/ask-once-0.2.2.tgz"},"maintainers":[{"name":"doowb","email":"brian.woodward@gmail.com"},{"name":"jonschlinkert","email":"github@sellside.com"}],"readme":"# ask-once [![NPM version](https://badge.fury.io/js/ask-once.svg)](http://badge.fury.io/js/ask-once)  [![Build Status](https://travis-ci.org/doowb/ask-once.svg)](https://travis-ci.org/doowb/ask-once)\n\n> Only ask a question one time and store the answer.\n\n## Install\n\nInstall with [npm](https://www.npmjs.com/)\n\n```sh\n$ npm i ask-once --save\n```\n\n## Usage\n\n```js\nvar ask = require('ask-once')();\n```\n\n**Ask a question**\n\n```js\nask.once('May I have your username?', function (err, answer) {\n  console.log(answer);\n});\n```\n\nThe user's answer is saved, and the question won't be asked again unless:\n\n* `force: true` is passed on the options, or\n* the answer is deleted directly\n\n## FAQ\n\n**Where are the answers stored?**\n\nThe user's answers are saved on a global config store that is uniquely identified to the application using `ask-once`.\n\n**Can I change where answers are stored?**\n\nYes, you can pass the name of a [data-store](https://github.com/jonschlinkert/data-store) with the `cwd` option set to whatever you want it to be. Here's an example:\n\n```js\n// pass the name of a data-store, so you can use\n// whatever storage location you want\nvar ask = require('ask-once')({\n  store: {\n    name: 'foo',\n    cwd: 'bar'\n  }\n});\n\nask.once('May I have your username?' function (err, answer) {\n  console.log(answer);\n});\n```\n\n## Docs\n\n### options\n\n> To re-ask questions or reset the stored values:\n\n* `options.force`: will re-ask the given question or questions, regardless of whether or not previously stored values exists.\n* `options.init`: will **delete the entire store** and start over again.\n\n### API\n\n### [Ask](index.js#L27)\n\nReturns a question-asking function that only asks a question if the answer is not already stored, or if forced.\n\n**Params**\n\n* `options` **{Object}**\n* `options.questions` **{Object}**: (optional) Options to be passed to [question-cache](https://github.com/jonschlinkert/question-cache)\n* `options.store` **{Object}**: (optional) Options to be passed to [data-store](https://github.com/jonschlinkert/data-store)\n\n**Example**\n\n```js\nvar ask = new Ask({questions: questions});\n```\n\n### [.set](index.js#L64)\n\nSet answer `key` with the given `value`. Answers are cached in memory on the `ask.answers.data` object, and they are also persisted to disk.\n\n**Params**\n\n* `key` **{String}**\n\n**Example**\n\n```js\nask.set('a', 'b');\nconsole.log(ask.answers.data.a)\n//=> 'b'\n```\n\n### [.get](index.js#L81)\n\nGet answer `key` from the answer store.\n\n**Params**\n\n* `key` **{String}**\n\n**Example**\n\n```js\nask.set('a', 'b');\nask.get('a');\n//=> 'b'\n```\n\n### [.del](index.js#L98)\n\nDelete an answer from the answer store.\n\n**Params**\n\n* `key` **{String|Array|Object}**: Pass a string or array of keys, or `{force: true}` to wipe out the entire store.\n\n**Example**\n\n```js\nask.del('foo');\nask.del(['foo', 'bar']);\n// delete the entire store\nask.del({force: true});\n```\n\n### [.once](index.js#L114)\n\nAsk a question only if the answer is not already stored. If\nthe answer is passed on the options the question is bypassed\nand the answer is be returned.\n\n**Params**\n\n* `question` **{String}**: Key of the question to ask.\n* `options` **{Object}**: Answers or options to force re-asking questions.\n* `cb` **{Function}**: Callback function with `err` and `answer`.\n\n## Examples\n\nFirst time the program is run, the user is prompted to answer a question:\n\n[![image](https://cloud.githubusercontent.com/assets/995160/9158076/78bf87e6-3ede-11e5-8bbc-dac8a55353c2.png)](https://www.npmjs.com/)\n\nAdditional runs of the program will skip prompting the user:\n\n[![image](https://cloud.githubusercontent.com/assets/995160/9158091/ec592b58-3ede-11e5-8f18-4fc4b1327d2b.png)](https://github.com/jonschlinkert/data-store)\n\nPassing the `init` option will delete all the stored answers and prompt the user to answer the question again:\n\n[![image](https://cloud.githubusercontent.com/assets/995160/9158111/22e24ff6-3edf-11e5-95c9-bc2314367557.png)](index.js#L27)\n\nAdditional runs after clearing the stop will return the newly saved answer:\n\n[![image](https://cloud.githubusercontent.com/assets/995160/9158120/43c16d60-3edf-11e5-8d85-a98b029fd743.png)](https://github.com/jonschlinkert/question-cache)\n\nPassing the `force` option will force the question to be asked:\n\n[![image](https://cloud.githubusercontent.com/assets/995160/9158137/740bef0e-3edf-11e5-898d-d9ce72f28ad2.png)](https://github.com/jonschlinkert/data-store)\n\nAdditional runs after forcing the question, will return the newly saved answer:\n\n[![image](https://cloud.githubusercontent.com/assets/995160/9158144/8fd63550-3edf-11e5-8daa-b19fa251bc66.png)](index.js#L64)\n\n## Related projects\n\n* [data-store](https://www.npmjs.com/package/data-store): Easily get, set and persist config data. | [homepage](https://github.com/jonschlinkert/data-store)\n* [inquirer](https://www.npmjs.com/package/inquirer): A collection of common interactive command line user interfaces. | [homepage](https://github.com/sboudrias/Inquirer.js#readme)\n* [question-cache](https://www.npmjs.com/package/question-cache): A wrapper around inquirer that makes it easy to create and selectively reuse questions. | [homepage](https://github.com/jonschlinkert/question-cache)\n* [question-helper](https://www.npmjs.com/package/question-helper): Template helper that asks a question in the command line and resolves the template with… [more](https://www.npmjs.com/package/question-helper) | [homepage](https://github.com/doowb/question-helper)\n\n## Running tests\n\nInstall dev dependencies:\n\n```sh\n$ npm i -d && npm test\n```\n\n## Contributing\n\nPull requests and stars are always welcome. For bugs and feature requests, [please create an issue](https://github.com/doowb/ask-once/issues/new).\n\n## Author\n\n**Brian Woodward**\n\n+ [github/doowb](https://github.com/doowb)\n+ [twitter/doowb](http://twitter.com/doowb)\n\n## License\n\nCopyright © 2015 Brian Woodward\nReleased under the MIT license.\n\n***\n\n_This file was generated by [verb-cli](https://github.com/assemble/verb-cli) on October 24, 2015._","publish_time":1439251621595,"_cnpm_publish_time":1439251621595,"dist-tags":{"latest":"0.6.2"}}