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

dotenv-vars-helper

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

dotenv-vars-helper

dotenv-vars-helper === [![Build Status](https://travis-ci.org/slowmove/dotenv-vars-helper.svg?branch=master)](https://travis-ci.org/slowmove/dotenv-vars-helper)

  • 1.2.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
2
increased by100%
Maintainers
1
Weekly downloads
 
Created
Source

dotenv-vars-helper

Build Status

When using environment variables, either in Heroku or thru a local .env file (use for example my package dotenv-vars to read them as process environment variables) all variables are set as strings. This is not optimal when you want to use them as toggles (booleans) or to hold some kind of integer value. This package help you out resolving this.

Installation

npm install --save dotenv-vars-helper

Usage

This package is exposing three methods

  • isSet("key") which should be used for toggles and will give you a boolean, true | false where any other string than true will give you false

  • enabled("key") gives you a boolean as well, but any string but "false" and bool false gives you true.

  • value("key", correctType = true) gives you the value in correct type, if not explicit told not to (then it gives you a string).

  • correctedType(key) which give you the value in the "correct" type, i.e. bool if it has a string value that is "true" or "false", number if it has a string value that really is a number etc.

Having your environment variables set in process.env via for example the package mentioned above, you can use this package as below

const envHelper = require("dotenv-vars-helper");

const isFeatureEnabled = envHelper.isSet("ENABLE_FEATURE_X");

FAQs

Package last updated on 19 Dec 2018

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