UNPKG

@barchart/common-js

Version:
105 lines (104 loc) 2.69 kB
/** * Simple implementation of a specification pattern, where instances * can be combined to form complex predicates. * * @public */ declare class Specification { /** * Evaluates the specification, returning true or false. * * @public * @param {*=} data * @returns {boolean} */ public evaluate(data?: any | undefined): boolean; /** * @protected * @param {*=} data * @returns {boolean} */ protected _evaluate(data?: any | undefined): boolean; /** * Wraps the current instance and another {@link Specification} into a new * specification which only evaluates to true when both wrapped specifications * evaluate to true. * * @public * @param {Specification} other * @returns {And} */ public and(other: Specification): And; /** * Wraps the current instance and another {@link Specification} into a new * specification which only evaluates to true when either of the wrapped * specifications evaluate to true. * * @public * @param {Specification} other * @returns {Or} */ public or(other: Specification): Or; /** * Wraps the current instance in a new {@link Specification} which evaluates * to the inverse result of the wrapped specification. * * @public * @returns {Not} */ public not(): Not; /** * Returns a string representation. * * @public * @returns {string} */ public toString(): string; } declare namespace Specification { export { And }; export { Or }; export { Not }; } export default Specification; /** * A {@link Specification} that combines two specifications with AND logic. * * @public * @extends {Specification} */ export class And extends Specification { /** * @param {Specification} specificationOne * @param {Specification} specificationTwo */ constructor(specificationOne: Specification, specificationTwo: Specification); #private; } /** * A {@link Specification} that combines two specifications with OR logic. * * @public * @extends {Specification} */ export class Or extends Specification { /** * @param {Specification} specificationOne * @param {Specification} specificationTwo */ constructor(specificationOne: Specification, specificationTwo: Specification); #private; } /** * A {@link Specification} that negates another specification. * * @public * @extends {Specification} */ export class Not extends Specification { /** * @param {Specification} otherSpecification */ constructor(otherSpecification: Specification); #private; }