Socket
Socket
Sign inDemoInstall

question-store

Package Overview
Dependencies
Maintainers
1
Versions
48
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

question-store - npm Package Compare versions

Comparing version 0.1.2 to 0.1.3

50

index.js

@@ -74,4 +74,4 @@ /*!

this.cache[question.name] = question;
this.answers[question.name] = question.data;
utils.set(this.cache, question.name, question);
utils.set(this.answers, question.name, question.data);
this.queue.push(question.name);

@@ -82,18 +82,20 @@ return this;

/**
* Get the `question` instance stored for the given `name`. This is the entire
* `Question` object, with all answers for all locales and directories.
* Get the answer object for question `name`, for the current locale and cwd.
*
* ```js
* var name = questions.question('name');
* var name = questions.get('name');
* //=> {name: 'Jon'}
*
* // specify a locale
* var name = questions.get('name', 'fr');
* //=> {name: 'Jean'}
* ```
* @param {String} `name`
* @return {Object} Returns the question instance.
* @param {String} `locale`
* @return {Object} Returns the question object.
* @api public
*/
Questions.prototype.question = function(name) {
if (!this.cache.hasOwnProperty(name)) {
throw new Error('question-store cannot find question "' + name + '"');
}
return this.cache[name];
Questions.prototype.get = function(name) {
return utils.get(this.cache, name);
};

@@ -118,3 +120,3 @@

Questions.prototype.get = function(name, locale) {
Questions.prototype.getAnswer = function(name, locale) {
return this.question(name).get(locale);

@@ -124,2 +126,26 @@ };

/**
* Get the `question` instance stored for the given `name`. This is the entire
* `Question` object, with all answers for all locales and directories.
*
* ```js
* var name = questions.question('name');
* ```
* @param {String} `name`
* @return {Object} Returns the question instance.
* @api public
*/
Questions.prototype.question = function(name) {
if (arguments.length > 1 || typeof name !== 'string') {
return this.set.apply(this, arguments);
}
var question = utils.get(this.cache, name);
if (typeof question === 'undefined') {
throw new Error('question-store cannot find question "' + name + '"');
}
return question;
};
/**
* Return true if question `name` has been answered for the current locale

@@ -126,0 +152,0 @@ * and the current working directory.

@@ -148,2 +148,6 @@ /*!

var answer = this.answer.get(opts.locale);
if (typeof answer === 'undefined') {
answer = this.answer.getDefault(opts.locale);
}
if (opts.force === true) {

@@ -159,6 +163,9 @@ this.answer.del(opts.locale);

if (typeof answer !== 'undefined') {
opts.default = answer;
opts.default = answer[this.name];
}
this.inquirer.prompt(opts, function(answer) {
if (opts.isDefault === true) {
this.answer.setDefault(answer);
}
if (opts.save !== false) {

@@ -165,0 +172,0 @@ this.answer.set(answer);

{
"name": "question-store",
"description": "Ask questions, persist the answers. Basic support for i18n and storing answers based on current working directory.",
"version": "0.1.2",
"version": "0.1.3",
"homepage": "https://github.com/jonschlinkert/question-store",

@@ -29,3 +29,3 @@ "author": "Jon Schlinkert (https://github.com/jonschlinkert)",

"get-value": "^2.0.0",
"inquirer": "github:jonschlinkert/inquirer.js#lazy",
"inquirer2": "github:jonschlinkert/inquirer2",
"isobject": "^2.0.0",

@@ -32,0 +32,0 @@ "lazy-cache": "^0.2.4",

@@ -76,5 +76,5 @@ # question-store [![NPM version](https://badge.fury.io/js/question-store.svg)](http://badge.fury.io/js/question-store)

### [.question](index.js#L92)
### [.get](index.js#L97)
Get the `question` instance stored for the given `name`. This is the entire `Question` object, with all answers for all locales and directories.
Get the answer object for question `name`, for the current locale and cwd.

@@ -84,3 +84,4 @@ **Params**

* `name` **{String}**
* `returns` **{Object}**: Returns the question instance.
* `locale` **{String}**
* `returns` **{Object}**: Returns the question object.

@@ -90,6 +91,11 @@ **Example**

```js
var name = questions.question('name');
var name = questions.get('name');
//=> {name: 'Jon'}
// specify a locale
var name = questions.get('name', 'fr');
//=> {name: 'Jean'}
```
### [.get](index.js#L116)
### [.getAnswer](index.js#L118)

@@ -115,4 +121,19 @@ Get the answer object for question `name`, for the current locale and cwd.

### [.isAnswered](index.js#L132)
### [.question](index.js#L134)
Get the `question` instance stored for the given `name`. This is the entire `Question` object, with all answers for all locales and directories.
**Params**
* `name` **{String}**
* `returns` **{Object}**: Returns the question instance.
**Example**
```js
var name = questions.question('name');
```
### [.isAnswered](index.js#L158)
Return true if question `name` has been answered for the current locale and the current working directory.

@@ -131,3 +152,3 @@

### [.del](index.js#L147)
### [.del](index.js#L173)

@@ -147,3 +168,3 @@ Delete the answer for question `name` for the current (or given) locale.

### [.erase](index.js#L162)
### [.erase](index.js#L188)

@@ -162,3 +183,3 @@ Erase all answers for question `name` from the file system.

### [.answer](index.js#L189)
### [.answer](index.js#L215)

@@ -184,3 +205,3 @@ Get the answer value for question `name`, for the current locale and cwd. Similar to `questions.get`, but only returns the answer value instead of the entire object.

### [.ask](index.js#L211)
### [.ask](index.js#L237)

@@ -311,3 +332,3 @@ Ask one or more questions, with the given `options` and callback.

### [.del](lib/question.js#L179)
### [.del](lib/question.js#L186)

@@ -326,3 +347,3 @@ Delete the answer for the current (or given) locale.

### [.erase](lib/question.js#L193)
### [.erase](lib/question.js#L200)

@@ -337,3 +358,3 @@ Delete the answer store (all answers for the question) from the file system.

### [.save](lib/question.js#L208)
### [.save](lib/question.js#L215)

@@ -380,2 +401,2 @@ Persist the answer for the current locale and cwd to disk.

_This file was generated by [verb-cli](https://github.com/assemble/verb-cli) on November 24, 2015._
_This file was generated by [verb-cli](https://github.com/assemble/verb-cli) on November 25, 2015._
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc