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

env-var

Package Overview
Dependencies
Maintainers
2
Versions
49
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

env-var - npm Package Compare versions

Comparing version 3.2.0 to 3.3.0

lib/accessors/enum.js

6

CHANGELOG.md

@@ -0,1 +1,7 @@

## 3.3.0 (26/06/18)
* Add `asEnum` functionality
## 3.2.0 (15/06/18)
* Remove @types/node dependency
## 3.1.0 (11/12/17)

@@ -2,0 +8,0 @@ * Update typings to correctly handle default values for numeric types.

22

env-var.d.ts

@@ -78,3 +78,3 @@

/**
* Verifies that the environment variable begin accessed is a valid URL and
* Verifies that the environment variable being accessed is a valid URL and
* returns it as a string. Uses the "is-url" module

@@ -85,6 +85,11 @@ */

/**
* Verifies that the environment variable begin accessed is a valid URL and
* Verifies that the environment variable being accessed is a valid URL and
* returns it as a core URL object. Uses the "is-url" module.
*/
asUrlObject: () => Url;
/**
* Verifies that the var being accessed is one of the given values
*/
asEnum: (validValues: string[]) => string;
}

@@ -169,12 +174,17 @@

/**
* Verifies that the environment variable begin accessed is a valid URL and
* Verifies that the environment variable being accessed is a valid URL and
* returns it as a string. Uses the "is-url" module
*/
asUrlString: () => string;
asUrlString: () => string|undefined;
/**
* Verifies that the environment variable begin accessed is a valid URL and
* Verifies that the environment variable being accessed is a valid URL and
* returns it as a core URL object. Uses the "is-url" module.
*/
asUrlObject: () => Url;
asUrlObject: () => Url|undefined;
/**
* Verifies that the var being accessed is one of the given values
*/
asEnum: (validValues: string[]) => string|undefined;
}

@@ -181,0 +191,0 @@

@@ -64,2 +64,4 @@ 'use strict'

asEnum: generateAccessor(container, varName, defValue, require('./accessors/enum')),
asFloatNegative: generateAccessor(container, varName, defValue, require('./accessors/float-negative')),

@@ -66,0 +68,0 @@ asFloatPositive: generateAccessor(container, varName, defValue, require('./accessors/float-positive')),

{
"name": "env-var",
"version": "3.2.0",
"description": "Solution for loading and sanatizing environment variables in node.js with correct typings",
"version": "3.3.0",
"description": "Solution for loading and sanitizing environment variables in node.js with correct typings",
"main": "env-var.js",

@@ -6,0 +6,0 @@ "typings": "env-var.d.ts",

@@ -8,3 +8,3 @@ # env-var

solution for loading and sanatizing environment variables in node.js with correct typings
solution for loading and sanitizing environment variables in node.js with correct typings

@@ -140,2 +140,5 @@ ## Install

```
#### asEnum(validValues: string[])
Converts the value to a string, and matches against the list of valid values.
If the value is not valid, an error will be raised describing valid input.

@@ -191,3 +194,3 @@ #### asInt()

#### asArray([delimiter])
#### asArray([delimiter: string])
Reads an environment variable as a string, then splits it on each occurence of

@@ -242,2 +245,5 @@ the specified _delimiter_. By default a comma is used as the delimiter. For

const commaArray = env.get('DASH_ARRAY').asArray('-');
// Returns the enum value if it's valid
const enumVal = env.get('STRING').asEnum(['dev', 'test', 'live'])
```

@@ -305,4 +311,7 @@

## Contributors
* @caccialdo
* @hhravn
* @itavy
* @MikeyBurkman
* @itavy
* @rmblstrp

@@ -309,0 +318,0 @@

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