predictype
Version:
PredicType is a library of pre-built and tested predicates for TypeScript, covering various data types and operations.
27 lines (26 loc) • 843 B
TypeScript
import { StringComparisonOper } from '../../enums/strings.js';
/**
* Compares two strings using the specified operation.
*
* @param source The first string.
* @param oper The comparison operation to perform (e.g. 'equals', 'greater_than').
* @param target The second string.
* @returns True if the comparison is valid according to the operator, otherwise false.
*
* @throws {Error} If the operation is not recognized.
*
* @example
* const a = 'foo';
* const b = 'bar';
*
* stringComparison(a, 'greater_than', b); // true
* stringComparison(a, 'equals', a); // true
*
* @remarks
* Supported Operators:
* - **EQUALS**: a === b
* - **NOT_EQUALS**: a !== b
* - **GREATER_THAN**: a > b
* - **LESS_THAN**: a < b
*/
export declare function stringComparison(source: string, oper: StringComparisonOper, target: string): boolean;