@nucypher/taco
Version:
### [`nucypher/taco-web`](../../README.md)
33 lines • 1.12 kB
JavaScript
import { Condition } from './condition';
import { compoundConditionSchema, CompoundConditionType, } from './schemas/compound';
export { compoundConditionSchema, CompoundConditionType, } from './schemas/compound';
export class CompoundCondition extends Condition {
constructor(value) {
super(compoundConditionSchema, {
conditionType: CompoundConditionType,
...value,
});
}
static withOperator(operands, operator) {
const asObjects = operands.map((operand) => {
if (operand instanceof Condition) {
return operand.toObj();
}
return operand;
});
return new CompoundCondition({
operator,
operands: asObjects,
});
}
static or(conditions) {
return CompoundCondition.withOperator(conditions, 'or');
}
static and(conditions) {
return CompoundCondition.withOperator(conditions, 'and');
}
static not(condition) {
return CompoundCondition.withOperator([condition], 'not');
}
}
//# sourceMappingURL=compound-condition.js.map