@nucypher/taco
Version:
### [`nucypher/taco-web`](../../README.md)
39 lines • 1.6 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.CompoundCondition = exports.CompoundConditionType = exports.compoundConditionSchema = void 0;
const condition_1 = require("./condition");
const compound_1 = require("./schemas/compound");
var compound_2 = require("./schemas/compound");
Object.defineProperty(exports, "compoundConditionSchema", { enumerable: true, get: function () { return compound_2.compoundConditionSchema; } });
Object.defineProperty(exports, "CompoundConditionType", { enumerable: true, get: function () { return compound_2.CompoundConditionType; } });
class CompoundCondition extends condition_1.Condition {
constructor(value) {
super(compound_1.compoundConditionSchema, {
conditionType: compound_1.CompoundConditionType,
...value,
});
}
static withOperator(operands, operator) {
const asObjects = operands.map((operand) => {
if (operand instanceof condition_1.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');
}
}
exports.CompoundCondition = CompoundCondition;
//# sourceMappingURL=compound-condition.js.map