@splitsoftware/splitio-commons
Version:
Split JavaScript SDK common components
52 lines (51 loc) • 1.44 kB
JavaScript
import { isString } from '../../../utils/lang';
export 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: isString(data.keys) ? [data.keys] : data.keys
}
}
]
},
partitions: [
{
treatment: treatment,
size: 100
}
],
label: "whitelisted ".concat(treatment)
};
}
else {
return {
conditionType: 'ROLLOUT',
matcherGroup: {
combiner: 'AND',
matchers: [
{
keySelector: null,
matcherType: 'ALL_KEYS',
negate: false
}
]
},
partitions: [
{
treatment: treatment,
size: 100
}
],
label: 'default rule'
};
}
}