Socket
Socket
Sign inDemoInstall

@availity/env-var

Package Overview
Dependencies
Maintainers
8
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.7.1 to 1.8.0

11

CHANGELOG.md

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

# [1.8.0](https://github.com/availity/sdk-js/compare/@availity/env-var@1.7.1...@availity/env-var@1.8.0) (2019-03-04)
### Features
* **env-var:** added extra param for setting default env var ([2f97472](https://github.com/availity/sdk-js/commit/2f97472))
## [1.7.1](https://github.com/availity/sdk-js/compare/@availity/env-var@1.7.0...@availity/env-var@1.7.1) (2019-02-12)

@@ -8,0 +19,0 @@

11

index.js

@@ -22,3 +22,3 @@ let environments = {

const { hostname } =
typeof windowOverride === 'string'
windowOverride === null || typeof windowOverride === 'string'
? getLocation(windowOverride)

@@ -53,5 +53,10 @@ : windowOverride.location;

export default function(varObj, windowOverride) {
export default function(varObj, windowOverride, defaultVar) {
const env = getCurrentEnv(windowOverride);
return typeof varObj[env] === 'undefined' ? varObj.local : varObj[env];
if (typeof varObj[env] !== 'undefined') {
return varObj[env];
}
return defaultVar || varObj.local;
}
{
"name": "@availity/env-var",
"version": "1.7.1",
"version": "1.8.0",
"description": "Availity-specific way to determine variables based on the current environment the code is running in",

@@ -26,3 +26,3 @@ "main": "src/index.js",

},
"gitHead": "9741ebcc564548d3f0e6def050b68529483b9350"
"gitHead": "bbe4925e0f7dab0f65feec23e45a25adfe0b6eae"
}

@@ -30,2 +30,4 @@ # env-var

- 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.

@@ -32,0 +34,0 @@ #### Example

@@ -200,3 +200,40 @@ import envVar, { setEnvironments } from '../index';

});
describe('with default env', () => {
beforeAll(() => {
setEnvironments({ app: 'app.example.com' });
});
test('should render default', () => {
setHostname('app.example.com');
expect(
envVar(
{
www: false,
local: false,
qa: false,
test: false,
},
null,
'default'
)
).toBe('default');
expect(
envVar(
{
app: true,
www: false,
local: false,
qa: false,
test: false,
},
null,
'default'
)
).toBe(true);
});
});
});
});
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