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 = ; // the given namespace is automatically uppercasedvar env = 'your-namespace'; env;console;//=> '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 = 'foo';
.set
Set a value on your process.env
namespace.
Params
key
{String}val
{any}
Example
env;console;//=> true
.get
Get a value from your process.env
namespace.
Params
key
{String}
Example
env;console;//=> true
.enabled
Returns the true
boolean if the value of key
is the string "true".
Params
key
{String}
Example
env;console;//=> true
.disabled
Returns the false
boolean if the value of key
is the string "false".
Params
key
{String}
Example
env;console;//=> false env;console;//=> true
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
, andhas
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#dev verb-generate-readme && 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.