UNPKG

@ganbarodigital/ts-lib-value-objects

Version:

Helps you create value objects and refined types for safer software

29 lines 830 B
/** * Entity<ID, T> describes the behaviour of data that has an identity. * * It is useful for ensuring all entities have a *minimal* set * of common behaviour, whether or not they share a common base class. */ export interface Entity<ID, T> { /** * this entity's identity. * * this is normally one (or more) fields from `T`. */ idOf(): ID; /** * a type-guard. It proves that an object is a wrapper around type `T` * that has ID `ID`. * * added mostly for completeness */ isEntity(): this is Entity<ID, T>; /** * returns the wrapped value * * for types passed by reference, we do NOT return a clone of any kind. * You have to be careful not to accidentally change this value. */ valueOf(): T; } //# sourceMappingURL=Entity.d.ts.map