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 🙏

© 2024 – Pkg Stats / Ryan Hefner

configstore-plain

v1.1.0

Published

Easily load and save config without having to think about where and how. Based on https://github.com/yeoman/configstore with additions for storing plain keys containing periods.

Downloads

6

Readme

configstore-plain

Easily load and persist config without having to think about where and how

Fork of https://github.com/yeoman/configstore to add new plain key methods (see https://github.com/yeoman/configstore/issues/39)

Config is stored in a JSON file located in $XDG_CONFIG_HOME or ~/.config. Example: ~/.config/configstore/some-id.json

See options below to modify storage location.

Usage

const Configstore = require('configstore');
const pkg = require('./package.json');

// Init a Configstore instance with an unique ID e.g.
// package name and optionally some default values
const conf = new Configstore(pkg.name, {foo: 'bar'});

conf.set('awesome', true);

console.log(conf.get('awesome'));
//=> true

console.log(conf.get('foo'));
//=> bar

// use dot notation to access nested properties (provided by `dot-prop` module)
conf.set('bar.baz', true);

console.log(conf.get('bar'));
//=> { baz: true }

console.log(conf.all);
//=> { foo: 'bar', awesome: true, bar: { baz: true } }

conf.del('awesome');

console.log(conf.get('awesome'));
//=> undefined

API

Note all functions apart from get() and getPlain() return the config object, so they can be chained - for example:

config.clear().set(newContents);

Configstore(packageName, [defaults], [options])

Create a new Configstore instance config.

packageName

Type: string

Name of your package.

defaults

Type: object

Default content to init the config store with.

options

Type: object

globalConfigPath

Type: boolean Default: false

Store the config at $CONFIG/package-name/config.json instead of the default $CONFIG/configstore/package-name.json. This is not recommended as you might end up conflicting with other tools, rendering the "without having to think" idea moot.

configFile

Type: string

Store the config file at the absolute location instead of the default (see above). Useful if (a) you want full control, (b) if you're using it for storing data other than 'config' data, or (c) to keep things together for a 'portable' installation.

config.set(key, value)

Set an item.

config.setPlain(key, value)

Set an item (does not turn periods in key into nested object properties).

config.set(object)

Set multiple items at once.

config.get(key)

Get an item.

config.getPlain(key, value)

Get an item (does not turn periods in key into nested object properties).

config.del(key)

Delete an item.

config.clear()

Delete all items.

config.all

Get all items as an object or replace the current config with an object:

conf.all = {
	hello: 'world'
};

config.size

Get the item count.

config.path

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.

License

BSD license Copyright Google