-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
34 lines (28 loc) · 774 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
'use strict';
/*!
* imports.
*/
var array = require('to-array.js');
var get = require('env-accessors').get;
/*!
* exports.
*/
module.exports = allowed;
/**
* Whether an environment variable's value is contained within an allow list.
* Allow list is provided by a comma-separated environment variable value.
*
* @param {String} allowListKey
* Name of environment variable containing allow list.
*
* @param {String} testValueKey
* Name of environment variable containing value to test against allow list.
*
* @return {Boolean}
* Whether environment varaible's value is contained within allow list.
*
* @api public
*/
function allowed(allowListKey, testValueKey) {
return array(get(allowListKey), ',').indexOf(get(testValueKey || 'NODE_ENV')) > -1;
}