predictype / predicates/queries/queryKey / queryKey
queryKey(
source,oper,key):boolean
Defined in: predicates/queries/queryKey.ts:26
Checks whether query parameters contain or lack a key.
URL | URLSearchParams
The query source to inspect (URL or URLSearchParams).
The key operation to perform (‘contains_key’ or ‘lacks_key’).
string
The key to check.
boolean
True if the key check is valid according to the operator, otherwise false.
If the operation is not recognized.
const source = new URLSearchParams('q=predicates&page=2');
const keyA = 'q';
const keyB = 'lang';
queryKey(source, 'contains_key', keyA); // true
queryKey(source, 'lacks_key', keyB); // true
Supported Operators: