@splitsoftware/splitio-commons
Version:
Split JavaScript SDK common components
56 lines (55 loc) • 1.59 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.parseCondition = void 0;
var lang_1 = require("../../../utils/lang");
function parseCondition(data) {
var treatment = data.treatment;
if (data.keys) {
return {
conditionType: 'WHITELIST',
matcherGroup: {
combiner: 'AND',
matchers: [
{
keySelector: null,
matcherType: 'WHITELIST',
negate: false,
whitelistMatcherData: {
whitelist: (0, lang_1.isString)(data.keys) ? [data.keys] : data.keys
}
}
]
},
partitions: [
{
treatment: treatment,
size: 100
}
],
label: "whitelisted " + treatment
};
}
else {
return {
conditionType: 'ROLLOUT',
matcherGroup: {
combiner: 'AND',
matchers: [
{
keySelector: null,
matcherType: 'ALL_KEYS',
negate: false
}
]
},
partitions: [
{
treatment: treatment,
size: 100
}
],
label: 'default rule'
};
}
}
exports.parseCondition = parseCondition;