predictype

predictype v0.13.0


predictype / predicates/queries / queryState

Function: queryState()

queryState(source, oper): boolean

Defined in: predicates/queries/queryState.ts:33

Checks whether query parameters are empty or not empty.

Parameters

source

URL | URLSearchParams

The query source to inspect (URL or URLSearchParams).

oper

QueryStateOper

The state operation to perform (‘is_empty’ or ‘is_not_empty’).

Returns

boolean

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

Throws

If the operation is not recognized.

Example

const sourceA = new URLSearchParams('q=predicate');
const sourceB = new URLSearchParams('');

queryState(sourceA, 'is_not_empty'); // true
queryState(sourceB, 'is_empty'); // true

Remarks

Supported Operators: