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

@availity/env-var

Package Overview
Dependencies
Maintainers
12
Versions
44
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@availity/env-var - npm Package Compare versions

Comparing version 1.9.1 to 1.9.2

index.d.ts

8

CHANGELOG.md

@@ -6,2 +6,10 @@ # Change Log

## [1.9.2](https://github.com/availity/sdk-js/compare/@availity/env-var@1.9.1...@availity/env-var@1.9.2) (2019-10-29)
**Note:** Version bump only for package @availity/env-var
## [1.9.1](https://github.com/availity/sdk-js/compare/@availity/env-var@1.9.0...@availity/env-var@1.9.1) (2019-04-17)

@@ -8,0 +16,0 @@

7

package.json
{
"name": "@availity/env-var",
"version": "1.9.1",
"version": "1.9.2",
"description": "Availity-specific way to determine variables based on the current environment the code is running in",
"main": "src/index.js",
"main": "index.js",
"types": "index.d.ts",
"repository": {

@@ -26,3 +27,3 @@ "type": "git",

},
"gitHead": "fb94eef197f4f9be7a70eedf053d5550ef4e619b"
"gitHead": "f0b6e96115e9503d98fb8bb8d9d30cc735f27701"
}
# env-var
> Get run-time environment variables for immutable builds
[![Version](https://img.shields.io/npm/v/@availity/env-var.svg?style=for-the-badge)](https://www.npmjs.com/package/@availity/env-var)
## Install

@@ -10,72 +13,2 @@

## Usage
### envVar (default export)
Given an object of possible values and get back the value for the current environment.
```js
import envVar from '@availity/env-var';
const myEnvVal = envVar(valuesObject[, windowOverride]);
```
#### Required params
- valuesObject: An object with keys which match the name of the potential environments. The value of the give for the current environment will be returned
#### Optional params
- windowOverride: String or Window Object which can be used to override the window which is used to determine the current hostname (which is used to determine the current environment)
- When string, the string will be takes an a fully qualified URL and the hostname will be parsed from it.
- When Window Object, the location hostname will be used.
- defaultVar: String or Object which will be the default value when the given var is not found. If not given, then
will use the `local` param in the `valuesObject` var.
#### Example
```js
import envVar from '@availity/env-var';
const myEnvVal = envVar({prod: '123', qa: '234', local: '345'});
/*
depending on which environment this is ran in, myEnvVal would be something different
in prod: myEnvVal will be '123'
in qa: myEnvVal will be '234'
in test: myEnvVal will be '345' (defaults to local if env is not found)
*/
```
### setEnvironments
Set the potential environments and the tests used to determine which environment the code is currently being executed in.
```js
import { setEnvironments } from '@availity/env-var';
setEnvironments(possibleEnvironments[, replaceExisting])
```
#### Required params
- possibleEnvironments: An object with keys which match the name of the potential environments and the values are the tests which are ran to determine if the environment is the current one.
These tests can be
- String: A string will be used to check an exact match.
- Regular Expression: A regex will be `test`d with the domain.
- Function: The function will be called and the result should be a boolean indicating if the environment is the current environment.
- Array: An array containing any of the above types.
#### Optional params
- replaceExisting: Boolean, when true possibleEnvironments will replace the existing environments instead of merging.
#### Example
```js
import { setEnvironments } from '@availity/env-var';
setEnvironments({
local: ['127.0.0.1', 'localhost'],
test: [/^t(?:(?:\d\d)|(?:est))-apps$/],
qa: [/^q(?:(?:\d\d)|(?:ap?))-apps$/],
prod: [/^apps$/],
myEnv: ['custom-stuff-here']
});
```
## [Documentation](https://availity.github.io/sdk-js/features/env-var)
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