"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
var isFunc_1 = __importDefault(require("./isFunc"));
var isArr_1 = __importDefault(require("../array/isArr"));
/**
* Simple helper to check wether a value is in/out of a list
*
* @param value The value to check
* @param list The list of values / value checkers
* @param mode The mode of checking, either whitelist or blacklist. Default to whitelist.
* @category validators
* @module valueIn
*/
function valueIn(value, list, mode) {
if (mode === void 0) { mode = 'whitelist'; }
// Normalize list arg
var normalizedList = (0, isArr_1.default)(list) ? list : [list];
// Iterate through the list
var isInList = normalizedList.some(function (iteratee) {
var isMatched = (function () {
if ((0, isFunc_1.default)(iteratee))
return iteratee(value);
return "".concat(iteratee) === "".concat(value);
})();
return isMatched;
});
return (mode === 'whitelist'
? isInList
: !isInList);
}
exports.default = valueIn;
Source