predictype / predicates/objects/objectKeys / objectKeysCompare
objectKeysCompare(
source,oper,keys):boolean
Defined in: predicates/objects/objectKeys.ts:33
Checks object keys for key-comparison operations (CONTAINS_, LACKS_, EQUALS_, etc.).
object
The object to check.
The key operation to perform (e.g. ‘contains_all_keys’, ‘lacks_all_keys’, ‘equals_keys’, …).
string[] | symbol[]
| The array of keys to check (string[] | symbol[]). |
boolean
True if the key check is valid according to the operator, otherwise false.
If the operation is not recognized or keys is missing.
const source = { a: 1, b: 2, c: 3 };
const keysA = ['a', 'b'];
const keysB = ['a', 'b', 'c'];
objectKeysCompare(source, 'contains_all_keys', keysA); // true
objectKeysCompare(source, 'equals_keys', keysB); // true
objectKeysCompare(source, 'lacks_all_keys', ['z']); // true
Supported Operators: