UNPKG

dino-core

Version:

A dependency injection framework for NodeJS applications

22 lines (21 loc) 1.1 kB
import { type Archetype, type Props } from './Archetype'; /** * Define a value object in the common sense of DDD (Domain-Driven Design). * The properties passed to the constructor will be set with the provided value * and will only be accessible for reading. */ export declare class ValueObject<T extends Props = Record<string, any>> implements Archetype { [x: string]: any; protected constructor(props?: T); /** * Compare two value objects for equality, the basic implementation is as following: * > if other object is not defined return false * > if this object and other object are not of the same type then return false * > if any of this object properties is not same as the same property on other object then return false * > otherwise return true * @param other the other archetype to compare * @returns true if the two value objects are same, false otherwise */ equals<T extends Archetype>(other: T): boolean; static create<P extends Props = Record<string, any>, Return extends ValueObject = ValueObject>(props?: P): Return; }