Product
Introducing Enhanced Alert Actions and Triage Functionality
Socket now supports four distinct alert actions instead of the previous two, and alert triaging allows users to override the actions taken for all individual alerts.
configstore
Advanced tools
Package description
The configstore npm package is used for easily loading and persisting config without having to think about where and how. It's ideal for storing user settings, application configurations, and other data that needs to be saved between sessions.
Creating and managing a config store
This code demonstrates how to create a new config store associated with a specific package and set default values. It also shows how to retrieve a value from the store.
const Configstore = require('configstore');
const packageJson = require('./package.json');
const conf = new Configstore(packageJson.name, {foo: 'bar'});
console.log(conf.get('foo'));
//=> 'bar'
Setting and getting data
This code shows how to set and get data in the config store. It also demonstrates the use of dot-notation to work with nested properties.
conf.set('awesome', true);
console.log(conf.get('awesome'));
//=> true
// Using dot-notation for nested properties
conf.set('bar.baz', true);
console.log(conf.get('bar'));
//=> { baz: true }
Deleting data
This code snippet illustrates how to delete a key-value pair from the config store.
conf.delete('awesome');
console.log(conf.get('awesome'));
//=> undefined
Accessing the entire store
This code example shows how to access the entire config store, which returns an object containing all the key-value pairs.
console.log(conf.all);
//=> { foo: 'bar', bar: { baz: true } }
Checking if a key exists
This code demonstrates how to check if a particular key exists in the config store.
console.log(conf.has('foo'));
//=> true
The 'rc' package is similar to configstore in that it handles configuration for Node.js applications. It reads from a variety of sources including command-line arguments, environment variables, and configuration files. Unlike configstore, 'rc' does not provide an API for setting or deleting configuration values programmatically.
The 'dotenv' package is used to load environment variables from a .env file into process.env. It is similar to configstore in that it helps manage application configuration. However, 'dotenv' is focused on environment variables and does not provide a direct API for setting, getting, or persisting data.
The 'nconf' package is a hierarchical node.js configuration with files, environment variables, command-line arguments, and atomic object merging. It provides a rich API for managing configuration data, similar to configstore, but with a focus on a hierarchical structure and multiple configuration sources.
Readme
Easily load and persist config without having to think about where and how.
Config is stored in a YAML file to make it simple for users to edit the config directly themselves. The file is located in $XDG_CONFIG_HOME
or ~/.config
. Eg: ~/.config/configstore/id-of-your-choosing.yml
var Configstore = require('configstore');
var packageName = require('./package').name;
// Init a Configstore instance with an unique ID eg. package name
// and optionally some default values
var conf = new Configstore(packageName, { foo: 'bar' });
conf.set('awesome', true);
console.log(conf.get('awesome')); // true
console.log(conf.get('foo')); // bar
conf.del('awesome');
console.log(conf.get('awesome')); // undefined
Set an item
Get an item
Delete an item
Get all items as an object or replace the current config with an object:
conf.all = {
hello: 'world'
};
Get the item count
Get the path to the config file. Can be used to show the user where the config file is located or even better open it for them.
BSD license
Copyright Google
FAQs
Easily load and save config without having to think about where and how
The npm package configstore receives a total of 7,507,277 weekly downloads. As such, configstore popularity was classified as popular.
We found that configstore demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 9 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.
Product
Socket now supports four distinct alert actions instead of the previous two, and alert triaging allows users to override the actions taken for all individual alerts.
Security News
Polyfill.io has been serving malware for months via its CDN, after the project's open source maintainer sold the service to a company based in China.
Security News
OpenSSF is warning open source maintainers to stay vigilant against reputation farming on GitHub, where users artificially inflate their status by manipulating interactions on closed issues and PRs.