env-cache

Get and set values on process.env using a namespace.
Follow this project's author, Jon Schlinkert, for updates on this project and others.
Install
Install with npm:
$ npm install --save env-cache
Why use this?
This library makes it easier to get and set values on process.env. Anywhere you need to access the process.env values, just create a new instance with the namespace you want to access.
Usage
var EnvCache = require('env-cache');
var env = new EnvCache('your-namespace');
env.set('production', true);
console.log(env.get('production'));
API
Create an instance of EnvCache with the given namespace. The namespace is automatically uppercased and is then used by the .set and .get methods to prefix keys.
Params
namespace {String}: The namespace to use on process.env.
Example
var env = new EnvCache('foo');
Set a value on your process.env namespace.
Params
Example
env.set('dev', true);
console.log(process.env.FOO_DEV);
Get a value from your process.env namespace.
Params
Example
env.set('dev', true);
console.log(env.get('dev'));
Returns the true boolean if the value of key is the string "true".
Params
Example
env.set('dev', true);
console.log(env.enabled('dev'));
Returns the false boolean if the value of key is the string "false".
Params
Example
env.set('dev', true);
console.log(env.disabled('dev'));
env.set('dev', false);
console.log(env.disabled('dev'));
About
Related projects
You might also be interested in these projects:
- base: Framework for rapidly creating high quality node.js applications, using plugins like building blocks | homepage
- cache-base: Basic object cache with
get, set, del, and has methods for node.js/javascript projects. | homepage
- data-store: Easily get, set and persist config data. | homepage
Contributing
Pull requests and stars are always welcome. For bugs and feature requests, please create an issue.
Building docs
(This project's readme.md is generated by verb, please don't edit the readme directly. Any changes to the readme must be made in the .verb.md readme template.)
To generate the readme, run the following command:
$ npm install -g verbose/verb
Running tests
Running and reviewing unit tests is a great way to get familiarized with a library and its API. You can install dependencies and run tests with the following command:
$ npm install && npm test
Author
Jon Schlinkert
License
Copyright © 2017, Jon Schlinkert.
Released under the MIT License.
This file was generated by verb-generate-readme, v0.6.0, on August 27, 2017.