Registry / devops / question-cache

question-cache

JSON →
library0.7.0jsnpmunverified

question-cache is a wrapper around inquirer for creating and reusing prompts in CLI applications, with support for caching answers and conditional questions. Version 0.7.0 is the latest stable release, though development appears to have slowed. Unlike raw inquirer, it provides a fluent API via .set() and .ask(), answer caching, and lifecycle hooks (ask/answer events). It depends on data-store for caching and uses inquirer2 by default.

npm install question-cache
INSTALL
IMPORT
SIG · QUESTION-CACHE
Q
question-cache
devopsjavascriptv0.7.0
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

Questions
var Questions = require('question-cache'); new Questions();
const Questions = require('question-cache');
Package is CJS-only. Use require().
default
var questions = require('question-cache')();
import questions from 'question-cache';
ESM import is not supported; use require().
set
var q = require('question-cache')(); q.set('name', 'What is your name?');
q.addQuestion('name', 'What is your name?');
addQuestion exists but set is preferred for chaining.

Basic setup and usage: create a Questions instance, set questions, and ask them with a callback.

var Questions = require('question-cache'); var q = new Questions(); q.set('name', 'What is your name?'); q.set('age', 'How old are you?'); q.ask(function(err, answers) { if (err) console.error(err); console.log(answers); });
Debug
Known issues
deprecatedThe package uses inquirer2 which is a fork; inquirer itself is more actively maintained.
fix
Consider using inquirer directly if you need active maintenance.
affects: >=0.7.0
gotchaWhen using .ask() without a callback, returned promise may not be supported; check version.
fix
Always provide a callback to .ask() for reliable execution.
affects: >=0.7.0
Errors
Common errors & fixes
TypeError: questions.ask is not a function
Misimporting or not instantiating correctly, e.g., using require('question-cache') instead of require('question-cache')()
fix
Use var questions = require('question-cache')(); or var Questions = require('question-cache'); new Questions();
Upgrade
Version history
0.7.0latest on npm
Audit
Dependencies
data-storerequiredUsed for persistence of cached answers across sessions
Agent activity
2 hits · last 30 days
node
2
Resources
question-cache — npm install question-cache · libregistry