predictype
Version:
PredicType is a library of pre-built and tested predicates for TypeScript, covering various data types and operations.
24 lines (23 loc) • 1.2 kB
TypeScript
import { ObjectKeysOper } from '../../enums/objects.js';
/**
* Checks object keys for key-comparison operations (CONTAINS_, LACKS_, EQUALS_, etc.).
*
* @param source The object to check.
* @param oper The key operation to perform (e.g. 'contains_all_keys', 'lacks_all_keys', 'equals_keys', ...).
* @param keys The array of keys to check (string[] | symbol[]).
* @returns True if the key check is valid according to the operator, otherwise false.
*
* @throws {Error} If the operation is not recognized or keys is missing.
*
* @remarks
* Supported Operators:
* - **CONTAINS_ALL_KEYS**: Object contains all the given keys
* - **CONTAINS_ANY_KEY**: Object contains at least one of the keys
* - **CONTAINS_ONLY_KEYS**: Object contains only the given keys
* - **CONTAINS_SYMBOL_KEYS**: Object contains at least one symbol key
* - **EQUALS_KEYS**: Object keys equal the given keys
* - **LACKS_ALL_KEYS**: Object lacks all the given keys
* - **ONLY_KEYS**: All object keys are in the given set
* - **STRICT_EQUALS_KEYS**: Object keys strictly equal the given keys
*/
export declare function objectKeysCompare(source: object, oper: ObjectKeysOper, keys: string[] | symbol[]): boolean;