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 = ;const config = ; // module exports a single function, that returns a new guarded cache per invocation config;config; try config; // throws, as this key has already been set config; // also throws as this key does not exist. catche console; ;
The backing cache is an ES6 Map
, so be sure to polyfill if using in older environments.