Skip to content

Commit

Permalink
update readme. update typings. update changelog
Browse files Browse the repository at this point in the history
  • Loading branch information
evanshortiss committed Jun 26, 2018
1 parent aa3ed9c commit 4ce2722
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 9 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
## 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)
* Update typings to correctly handle default values for numeric types.
* Ensure an error is thrown when `asArray` does not detect at least a single non-empty value.
Expand Down
10 changes: 8 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ The same as _asJson_ but checks that the data is a JSON Array, e.g [1,2].
#### asJsonObject()
The same as _asJson_ but checks that the data is a JSON Object, e.g {a: 1}.

#### asArray([delimiter])
#### asArray([delimiter: string])
Reads an environment variable as a string, then splits it on each occurence of
the specified _delimiter_. By default a comma is used as the delimiter. For
example a var set to "1,2,3" would become ['1', '2', '3'].
Expand Down Expand Up @@ -239,6 +239,9 @@ const commaArray = env.get('COMMA_ARRAY').asArray();

// Returns an array if defined, or undefined if not set
const commaArray = env.get('DASH_ARRAY').asArray('-');

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


Expand Down Expand Up @@ -301,8 +304,11 @@ describe('concat.js', function () {
```

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


## Contributing
Expand Down
22 changes: 16 additions & 6 deletions env-var.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,16 +75,21 @@ interface IPresentVariable {
asStrictBool: () => boolean;

/**
* 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;

/**
* 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;
}

interface IOptionalVariable {
Expand Down Expand Up @@ -164,16 +169,21 @@ interface IOptionalVariable {
asStrictBool: () => boolean|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 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;
}

declare class EnvVarError extends Error {}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "env-var",
"version": "3.2.0",
"version": "3.3.0",
"description": "Solution for loading and sanitizing environment variables in node.js with correct typings",
"main": "env-var.js",
"typings": "env-var.d.ts",
Expand Down

0 comments on commit 4ce2722

Please sign in to comment.