Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

mini-config

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mini-config

Minimal configuration provider with guard for undefined values, and resetting them.

  • 1.0.1
  • unpublished
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
Maintainers
1
Weekly downloads
 
Created
Source

Build Status

Mini configuration provider

Minimal wrapper around a Map that tries to protect you from referencing undefined variables, or from redefining keys at runtime.

Rationale is that sometimes, you just want something very straightforward to setup config variables and pass them around, without the overhead of a large scale module, although sometimes that's needed. A warning if some broken code is overwriting config, or if you are mistyping / referencing a non-existent key is also handy.

Installation

$ npm install --save mini-config

API


// project-config.js or whatever

const makeConfig = require('mini-config');
const config = makeConfig(); // module exports a single function, that returns a new guarded cache per invocation

config.set('foo','bar');
config.set('baz', false);

try {
    config.set('foo','bla'); // throws, as this key has already been set
    config.get('bla'); // also throws as this key does not exist.
} catch(e) {
    console.log(e);
}


export default config;


The backing cache is an ES6 Map, so be sure to polyfill if using in older environments.

FAQs

Package last updated on 29 Mar 2016

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc