predictype

predictype v0.8.1


predictype / predicates/symbols/symbolComparison / symbolComparison

Function: symbolComparison()

symbolComparison(source, oper, target): boolean

Defined in: predicates/symbols/symbolComparison.ts:25

Compares two symbols for equality or inequality using the specified operation.

Parameters

source

symbol

The first symbol to compare.

oper

SymbolComparisonOper

The comparison operation to perform (e.g. ‘equals’, ‘not_equals’).

target

symbol

The second symbol to compare.

Returns

boolean

True if the comparison is valid according to the operator, otherwise false.

Throws

If the operation is not recognized.

Example

const a = Symbol('foo');
const b = Symbol('foo');

symbolComparison(a, 'equals', a); // true
symbolComparison(a, 'not_equals', b); // true

Remarks

Supported Operators: