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 🙏

© 2025 – Pkg Stats / Ryan Hefner

uberconfig

v0.2.1

Published

configuration manager for multi-module configs

Readme

uberconfig

Build Status Coverage Status bitHound Overall Score bitHound Dependencies semantic-release Love and Peace

configuration manager for multi-module configs.

In order to...

In order to share configuration between parts of an application that do not even know each other.

Multiple configuration consumers come into an agreement by passing a default value with each request for a configuration value. — Given the default values are equal, we assume the consumers are up to the same thing.

This will hopefully lead to a world with fever unnecessary namespaces and more communication between maintainers of modules that share same intentions. In the case of conflicting default values, I would love to see the conflicting parties come to an agreement together instead of expanding the namespaces.

<3

Install

npm install uberconfig

Use

const Uberconfig = require('uberconfig');
const config = new Uberconfig({
  foo: 'bar',
  lorem: {
    ipsum: 'dolor',
    sit: 'amet'
  }
});

config.get('foo', 'A');
// 'bar'

config.get('lorem.ipsum', 'B');
// 'dolor'

config.get('foo.bar', 'C');
// 'C'

config.get('foo');
// throws 'can not get uberconfig "foo" without default value'

config.get('lorem.sit', false);
// throws 'config value for "lorem.sit" must be of type boolean but is string'

config.get('foo', 'D');
// throws 'conflicting default values for uberconfig "foo" expected "D" to equal "A"'

config.get('foo', 'D', function resolveDefaultConflict(myDefault, conflicts, key) {
  myDefault.defaultValue = conflicts[0].defaultValue;

  return myDefault;
});
// 'bar'

config.request({
  'lorem.sit': {
    default: 'something',
    as: 'newKey'
  },
  'bar.foo': {
    default: 'baz'
  }
});
// {newKey: 'amet', bar: {foo: 'baz'}}

environment variables and CLI params

Given script foo.js:

const Uberconfig = require('uberconfig');
console.log(new Uberconfig().get('foo.bar', 'hey'));

Shell usage:

node foo.js
# logs: hey

UBERCONFIG_FOO_BAR=ho node foo.js
# logs: ho

node foo.js --uc-foo-bar='lets go'
# logs: lets go

CLI param > environment variable > config value > default value

Options

can be passed as second parameter into construction

new Uberconfig(config, options);
  • options.envPrefix:String

    Default: UBERCONFIG_

    prefix for environment variable lookup

  • options.envConverter:Function

    function converting a config key to environment variable name
    default will convert a.foo to A_FOO
    In combination with envPrefix a.foo can be set using UBERCONFIG_A_FOO=bar

  • options.cliPrefix:String

    Default: uc-

    prefix for CLI parameter lookup

  • options.cliConverter:Function

    function converting a config key to CLI parameter name
    default will convert a.foo to a-foo
    In combination with cliPrefix a.foo can be set using --uc-a-foo=bar

Multi type values

In case you do not know which type a configuration variable must have by default, wrap it up as a MultiTypeValue.

Hint: Do not do this, it's an anti-pattern.
May be required when you pass though parts of the uberconfig API...

See implementation of MultiTypeValue for details

const Uberconfig = require('uberconfig');
const MultiTypeValue = Uberconfig.MultiTypeValue;

class MyMultiTypeValue extends MultiTypeValue {
  convertBoolean(value) {
    if (value === 5) {
      return true;
    }

    return false;
  }
  convertString(value) {
    if (value === 5) {
      return 'ipsum';
    }

    return value + '';
  }
}

const someUserInput = 5;
const myConf = {
  foo: {
    bar: new MyMultiTypeValue(someUserInput)
  }
};

const booleanDefaultVal = false;
console.log(new Uberconfig(myConf).get('foo.bar', booleanDefaultVal));
// logs true

const stringDefaultVal = 'lorem';
console.log(new Uberconfig(myConf).get('foo.bar', stringDefaultVal));
// logs 'ipsum'

License

The MIT License

Copyright (C) 2016 Hannes Diercks

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.