-
Notifications
You must be signed in to change notification settings - Fork 0
/
Or.ts
43 lines (38 loc) · 757 Bytes
/
Or.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import {
Conditions,
Scalar,
ScalarLike
} from '@main';
/**
* Logical disjunction operator.
*/
export class Or implements Scalar<boolean> {
/**
* Conditions.
*/
private readonly conditions: Iterable<boolean>;
/**
* Ctor.
* @param conditions Conditions.
*/
constructor(...conditions: ScalarLike<boolean>[]) {
this.conditions = new Conditions(conditions);
}
/**
* Type determinant.
*/
public isScalar(): true {
return true;
}
/**
* Get the value.
*/
public value(): boolean {
for (const condition of this.conditions) {
if (condition) {
return true;
}
}
return false;
}
}