Micro check library providing comprehensive type checking and validation operations across different JavaScript environments
—
Pending
Does it follow best practices?
Impact
Pending
No eval scenarios have been run
Pending
The risk profile of this skill
Functions for validating arrays, objects, and their properties.
Checks if a given value is present in an array.
/**
* Checks if the given item is in array
* @param value - Value to search for
* @param array - Array to search in
* @returns True if value is found in array
* Interfaces: not
*/
function inArray(value: any, array: any[]): boolean;Usage Example:
is.inArray(2, [1, 2, 3]); // true
is.inArray(4, [1, 2, 3]); // false
is.not.inArray(4, [1, 2, 3]); // trueChecks if the given array is sorted, with optional comparison operator.
/**
* Checks if the given array is sorted
* @param array - Array to check
* @param sign - Optional comparison operator ('>=', '>', '<=', '<')
* @returns True if array is sorted according to the specified order
* Interfaces: not, all, any
*/
function sorted(array: any[], sign?: string): boolean;Usage Example:
is.sorted([1, 2, 3]); // true (default: ascending)
is.sorted([1, 2, 4, 3]); // false
is.sorted([1, 1, 2, 2], '>='); // true
is.sorted([1, 2, 3, 4], '>'); // true
is.sorted([4, 3, 3, 1], '<='); // true
is.sorted([4, 3, 2, 1], '<'); // true
is.sorted([1, 2, 3, 3], '>'); // false
is.not.sorted([5, 4, 3]); // true
is.all.sorted([1, 2], [3, 4]); // true
is.any.sorted([1, 2], [5, 4]); // trueChecks if an object has exactly the specified number of properties.
/**
* Checks if objects' property count is equal to given count
* @param object - Object to check
* @param count - Expected number of properties
* @returns True if object has exactly count properties
* Interfaces: not
*/
function propertyCount(object: any, count: number): boolean;Usage Example:
is.propertyCount({this: 'is', 'sample': 'object'}, 2); // true
is.propertyCount({this: 'is', 'sample': 'object'}, 3); // false
is.not.propertyCount({}, 2); // trueChecks if a specific property is defined on an object.
/**
* Checks if the given property is defined on object
* @param object - Object to check
* @param property - Property name to check for
* @returns True if property exists on object
* Interfaces: not
*/
function propertyDefined(object: any, property: string): boolean;Usage Example:
is.propertyDefined({yeap: 'yeap'}, 'yeap'); // true
is.propertyDefined({yeap: 'yeap'}, 'nope'); // false
is.not.propertyDefined({}, 'nope'); // true