import { shallowEqual } from "shallow-equal-object"; type Primitive = string | boolean | number; export interface IValueObjectOptions { label?: string; path?: string; } export abstract class ValueObject { readonly props: T; constructor(value: T) { this.props = typeof value === "object" ? Object.freeze(value) : value; } get value(): T { return this.props; } public abstract toPrimitive(): Primitive; public equals(vo: ValueObject): boolean { if (vo === null || vo === undefined) { return false; } if (vo.props === undefined) { return false; } return shallowEqual(this.props, vo.props); } } /*export type TComposedValueObject = { [key: string]: ValueObject; }; */