-
Notifications
You must be signed in to change notification settings - Fork 0
/
Equals.ts
44 lines (39 loc) · 812 Bytes
/
Equals.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
44
import {
Scalar,
ScalarLike,
ScalarOf
} from '@main';
/**
* Compare values for equality.
*/
export class Equals<T> implements Scalar<boolean> {
/**
* Source value.
*/
private readonly source: Scalar<T>;
/**
* Compared value.
*/
private readonly compared: Scalar<T>;
/**
* Ctor.
* @param source Value.
* @param compared Compared.
*/
constructor(source: ScalarLike<T>, compared: ScalarLike<T>) {
this.source = new ScalarOf(source);
this.compared = new ScalarOf(compared);
}
/**
* Type determinant.
*/
public isScalar(): true {
return true;
}
/**
* Gets the value.
*/
public value(): boolean {
return this.source.value() === this.compared.value();
}
}