npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

inquirer-store

v1.1.2

Published

Make inquirer's answers persistence even be aborted halfway

Readme

inquirer-store

Build status Test coverage NPM version NPM Downloads Prettier Conventional Commits

Make inquirer's answers persistence even be aborted halfway

How it works?

  1. Get default answers by store, if null, turn to step 3.
  2. Reset default field of each config.
  3. Detect each answer's acceptance by calling prompt.ui.process.subscribe, then calls store.set / store.write for saving.

Installation

npm install inquirer-store
# or use yarn
yarn add inquirer-store

API

inquirerStore

index.js:37-62

Make inquirer's answers persistence

Parameters

  • prompt {Function}
  • config same as inquirer
  • opts Object
    • opts.store {Store} Use which store
    • opts.deniesStoreKey {string} When config contains deniesStoreKey and equals true, the prompt's value will not be saved. (optional, default 'deniesStore')
    • opts.mode {'duplex'|'write'|'read'} The mode about dealing with store
      • duplex: Read and then write with store
      • write: Just write data to store
      • read: Just read data from store (optional, default 'duplex')

Examples

const inquirerStore = require('inquirer-store')
const FileStore = require('inquirer-store/FileStore')
const inquirer = require('inquirer')

inquirerStore(
  inquirer.prompt,
  [
    { type: 'input', message: 'Hi...', name: 'name' },
    { type: 'input', message: 'Hi...', name: 'deny', deniesStore: true }
  ],
  {
    store: new FileStore({ storePath: '/path/to/where.json' })
  }
).then(answers => {
  // `answers` would be setting in `default` as default value at next time
  //  but excluding `answers.deny`
})

Store

Store.js:30-98

Base Class for storing to anywhere, don't use it directly

Parameters

  • options {object}

Examples

const Store = require('inquirer-store/Store')
// Write customized store class
class MyStore extends Store {
  static defaultOptions = {
    data: { name: 'imcuttle' }
  }
  // Note: It must be a sync operation
  _read() {
    const { data } = this.options
    return data
  }
  // Note: It must be a sync operation
  _write(data) {
    // Save data for persistence here
  }
}

options

Store.js:37-37

extends from this.constructor.defaultOptions and options

Type: object

data

Store.js:43-43

Existing data in actually

Type: object

get

Store.js:57-59

Get this.data[name]

Parameters
  • name {string}

Returns any

set

Store.js:67-69

Set this.data[name] to be value

Parameters
  • name {string}
  • value {any}

unset

Store.js:76-78

Delete this.data[name]

Parameters
  • name {string}

clear

Store.js:84-86

Clear this.data

write

Store.js:95-97

Write this.data for persistence

Parameters
  • data (optional, default {})

FileStore

FileStore.js:24-52

Extends Store

Store's implementation in file system

Parameters

  • options {object}
    • options.key {string|null} When null, use store from storePath as data, otherwise use store[key] as data. (optional, default null)
    • options.storePath {string|null] - File path for storing data (optional, default null)
    • options.parse {string: string => object} Parse the text from file storePath (optional, default JSON.parse)
    • options.stringify {data: object => string} Stringify data for saving in storePath (optional, default JSON.stringify)
    • options.fs It's useful for mocking data by overriding existsSync / readFileSync / writeFileSync methods (optional, default require('fs'))

fillConfigDefault

index.js:79-89

Fill config's default field

Parameters

  • config {Array | object}
  • store {Store}

Examples

const { fillConfigDefault } = require('inquirer-store')

fillConfigDefault(
  [{ type: 'input', name: 'name', default: 'foo' }],
  new FileStore({ storePath: '/path/to/where.json' })
)
// [{ type: 'input', name: 'name', default: 'the value that you has inputted in last time' }]

Returns Array<object>

Contributing

  • Fork it!
  • Create your new branch:
    git checkout -b feature-new or git checkout -b fix-which-bug
  • Start your magic work now
  • Make sure npm test passes
  • Commit your changes:
    git commit -am 'feat: some description (close #123)' or git commit -am 'fix: some description (fix #123)'
  • Push to the branch: git push
  • Submit a pull request :)

Authors

This library is written and maintained by imcuttle, [email protected].

License

MIT - imcuttle 🐟