@synet/patterns
Version:
Robust, battle-tested collection of stable patterns used in Synet packages
25 lines (24 loc) • 755 B
TypeScript
/**
* Base specification pattern implementation.
*
* Specifications encapsulate query logic, making it reusable and composable.
* They represent a predicate that determines if an object satisfies some criteria.
*/
export declare abstract class Specification<T> {
/**
* Determines if the candidate object satisfies this specification
*/
abstract isSatisfiedBy(candidate: T): boolean;
/**
* Combines this specification with another using AND operator
*/
and(other: Specification<T>): Specification<T>;
/**
* Combines this specification with another using OR operator
*/
or(other: Specification<T>): Specification<T>;
/**
* Negates this specification
*/
not(): Specification<T>;
}