predictype

predictype v0.8.1


predictype / predicates/symbols / symbolState

Function: symbolState()

symbolState(source, oper): boolean

Defined in: predicates/symbols/symbolState.ts:24

Checks the state of a symbol (global or local) using the specified operation.

Parameters

source

symbol

The symbol to check.

oper

SymbolStateOper

The state operation to perform (e.g. ‘is_global’, ‘is_local’).

Returns

boolean

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

Throws

If the operation is not recognized.

Example

const globalSym = Symbol.for('foo');
const localSym = Symbol('bar');

symbolState(globalSym, 'is_global'); // true
symbolState(localSym, 'is_local'); // true

Remarks

Supported Operators: