CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/npm-is-js

Micro check library providing comprehensive type checking and validation operations across different JavaScript environments

Pending
Quality

Pending

Does it follow best practices?

Impact

Pending

No eval scenarios have been run

SecuritybySnyk

Pending

The risk profile of this skill

Overview
Eval results
Files

collection-validation.mddocs/

Collection Validation

Functions for validating arrays, objects, and their properties.

Capabilities

Array Operations

In Array Check

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]);   // true

Sorted Check

Checks 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]);  // true

Object Operations

Property Count Check

Checks 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);                           // true

Property Defined Check

Checks 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

docs

collection-validation.md

configuration.md

date-time.md

environment-detection.md

index.md

numeric-operations.md

pattern-matching.md

presence-checking.md

string-checking.md

type-checking.md

tile.json