env-cache v0.1.0
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-cacheWhy 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');
// the given namespace is automatically uppercased
var env = new EnvCache('your-namespace');
env.set('production', true);
console.log(env.get('production'));
//=> 'true'API
EnvCache
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 onprocess.env.
Example
var env = new EnvCache('foo');.set
Set a value on your process.env namespace.
Params
key{String}val{any}
Example
env.set('dev', true);
console.log(process.env.FOO_DEV);
//=> true.get
Get a value from your process.env namespace.
Params
key{String}
Example
env.set('dev', true);
console.log(env.get('dev'));
//=> true.enabled
Returns the true boolean if the value of key is the string "true".
Params
key{String}
Example
env.set('dev', true);
console.log(env.enabled('dev'));
//=> true.disabled
Returns the false boolean if the value of key is the string "false".
Params
key{String}
Example
env.set('dev', true);
console.log(env.disabled('dev'));
//=> false
env.set('dev', false);
console.log(env.disabled('dev'));
//=> trueAbout
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, andhasmethods 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#dev verb-generate-readme && verbRunning 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 testAuthor
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.
8 years ago