
Security News
Deno 2.2 Improves Dependency Management and Expands Node.js Compatibility
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
question-store
Advanced tools
Ask questions, persist the answers. Basic support for i18n and storing answers based on current working directory.
Ask questions, persist the answers. Basic support for i18n and storing answers based on current working directory.
Similar to question-cache, but persists answers to disk and supports locales and storing answers based on current working directory.
Install with npm
$ npm i question-store --save
var Questions = require('question-store');
Create an instance of Questions
with the given options
.
Params
options
{Object}: question store optionsExample
var Questions = new Questions(options);
Queue up a question to be asked at a later point. Creates an instance of Question, so any Question
options or settings may be used.
Params
value
{Object|String}: Question object, message (string), or options object.locale
{String}: Optionally pass the locale to use, otherwise the default locale is used.Example
questions.set('drink', 'What is your favorite beverage?');
// or
questions.set('drink', {
type: 'input',
message: 'What is your favorite beverage?'
});
// or
questions.set({
name: 'drink'
type: 'input',
message: 'What is your favorite beverage?'
});
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
var name = questions.question('name');
Get the answer object for question name
, for the current locale and cwd.
Params
name
{String}locale
{String}returns
{Object}: Returns the question object.Example
var name = questions.get('name');
//=> {name: 'Jon'}
// specify a locale
var name = questions.get('name', 'fr');
//=> {name: 'Jean'}
Return true if question name
has been answered for the current locale and the current working directory.
Params
name
{String}: Question namelocale
{String}: Optionally pass a localeExample
question.isAnswered(locale);
Delete the answer for question name
for the current (or given) locale.
Params
name
{String}: Question namelocale
{String}: Optionally pass a localeExample
question.del(locale);
Erase all answers for question name
from the file system.
Params
name
{String}: Question nameExample
question.erase(name);
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.
Params
name
{String}locale
{String}returns
{Object}: Returns the question object.Example
var name = questions.answer('name');
//=> 'Jon'
// specify a locale
var name = questions.answer('name', 'fr');
//=> 'Jean'
Ask one or more questions, with the given options
and callback.
Params
queue
{String|Array}: Name or array of question names.options
{Object|Function}: Question options or callback functioncallback
{Function}: callback functionExample
questions.ask(['name', 'description'], function(err, answers) {
console.log(answers);
});
Create new Question
store name
, with the given options
.
Params
name
{String}: The question property name.options
{Object}: Store optionsExample
var question = new Question(name, options);
Set the answer to the question for the current (or given) locale, at the current working directory.
Params
locale
{String}: Optionally pass a localeExample
question.set('foo');
Get the answer for the current (or given) locale for the current working directory.
Params
locale
{String}: Optionally pass a localeExample
question.get(locale);
Return true if the question has been answered for the current locale and the current working directory.
Params
locale
{String}: Optionally pass a localeExample
question.isAnswered(locale);
Set the default answer to use for the current (or given) locale, at the current working directory.
Params
locale
{String}: Optionally pass a localeExample
question.setDefault('foo');
Return true if the question has been given a default answer for the current (or given) locale, at the current working directory.
Params
locale
{String}: Optionally pass a localeExample
question.hasDefault('foo');
Ask the question.
options.force
is true, the answer will be asked asked even if the answer is already stored.options.save
is false, the answer will not be persisted to the file system, and the question will be re-asked each time .ask()
is called (which means it's also not necessary to define force
when save
is false).Params
options
{Object|Function}: Question options or callback functioncallback
{Function}: callback functionExample
question.ask({force: true}, function(err, answer) {
console.log(answer);
});
Delete the answer for the current (or given) locale.
Params
locale
{String}: Optionally pass a localeExample
question.del(locale);
Delete the answer store (all answers for the question) from the file system.
Example
question.erase();
Persist the answer for the current locale and cwd to disk.
Example
question.save();
Install dev dependencies:
$ npm i -d && npm test
Pull requests and stars are always welcome. For bugs and feature requests, please create an issue.
Jon Schlinkert
Copyright © 2015 Jon Schlinkert Released under the MIT license.
This file was generated by verb-cli on November 24, 2015.
FAQs
Ask questions, persist the answers. Basic support for i18n and storing answers based on current working directory.
The npm package question-store receives a total of 31,271 weekly downloads. As such, question-store popularity was classified as popular.
We found that question-store demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
Security News
React's CRA deprecation announcement sparked community criticism over framework recommendations, leading to quick updates acknowledging build tools like Vite as valid alternatives.
Security News
Ransomware payment rates hit an all-time low in 2024 as law enforcement crackdowns, stronger defenses, and shifting policies make attacks riskier and less profitable.