@juspay/neurolink
Version:
Universal AI Development Platform with working MCP integration, multi-provider support, and professional CLI. Built-in tools operational, 58+ external MCP servers discoverable. Connect to filesystem, GitHub, database operations, and more. Build, test, and
98 lines (97 loc) • 2.59 kB
JavaScript
/**
* Type Utilities - Centralized type checking functions
*
* Consolidates common type checking patterns to reduce code duplication
* and provide consistent type guards across the codebase.
*/
/**
* Type guard to check if a value is a non-null object
* Excludes arrays and null values
*
* @param value - Value to check
* @returns true if value is a non-null object (excluding arrays)
*/
export function isObject(value) {
return typeof value === "object" && value !== null && !Array.isArray(value);
}
/**
* Type guard to check if a value is a non-null object (including arrays)
*
* @param value - Value to check
* @returns true if value is a non-null object (including arrays)
*/
export function isNonNullObject(value) {
return typeof value === "object" && value !== null;
}
/**
* Type guard to check if a value is a plain object with string keys
*
* @param value - Value to check
* @returns true if value is a plain object with string keys
*/
export function isPlainObject(value) {
return isObject(value) && Object.getPrototypeOf(value) === Object.prototype;
}
/**
* Type guard to check if a value is an array
*
* @param value - Value to check
* @returns true if value is an array
*/
export function isArray(value) {
return Array.isArray(value);
}
/**
* Type guard to check if a value is a string
*
* @param value - Value to check
* @returns true if value is a string
*/
export function isString(value) {
return typeof value === "string";
}
/**
* Type guard to check if a value is a number
*
* @param value - Value to check
* @returns true if value is a number and not NaN
*/
export function isNumber(value) {
return typeof value === "number" && !isNaN(value);
}
/**
* Type guard to check if a value is a boolean
*
* @param value - Value to check
* @returns true if value is a boolean
*/
export function isBoolean(value) {
return typeof value === "boolean";
}
/**
* Type guard to check if a value is a function
*
* @param value - Value to check
* @returns true if value is a function
*/
export function isFunction(value) {
return typeof value === "function";
}
/**
* Type guard to check if a value is null or undefined
*
* @param value - Value to check
* @returns true if value is null or undefined
*/
export function isNullish(value) {
return value === null || value === undefined;
}
/**
* Type guard to check if a value is defined (not undefined)
*
* @param value - Value to check
* @returns true if value is not undefined
*/
export function isDefined(value) {
return value !== undefined;
}