A social knowledge tool for researchers built on ATProto
1interface ValueObjectProps {
2 [index: string]: any;
3}
4
5/**
6 * @desc ValueObjects are objects that we determine their
7 * equality through their structrual property.
8 */
9
10export abstract class ValueObject<T extends ValueObjectProps> {
11 public props: T;
12
13 constructor(props: T) {
14 let baseProps: any = {
15 ...props,
16 };
17
18 this.props = baseProps;
19 }
20
21 public equals(vo?: ValueObject<T>): boolean {
22 if (vo === null || vo === undefined) {
23 return false;
24 }
25 if (vo.props === undefined) {
26 return false;
27 }
28 return JSON.stringify(this.props) === JSON.stringify(vo.props);
29 }
30}