UNPKG

@juspay/neurolink

Version:

The pipe layer of an AI nervous system: one interface connecting provider neurons to your application, across three inference types — generate, stream and decide. `decide` returns typed, calibrated judgements from a non-generative model (~400ms, ~$0.00002

49 lines (48 loc) • 1.5 kB
/** * Comprehensive Type Alias Library * Centralizes commonly used complex types to improve readability and maintainability */ // ============================================================================ // TYPE GUARDS AND UTILITIES // ============================================================================ /** * Type guard for checking if value is a StandardRecord * * @param value - Value to check * @returns True if value is a non-null object (but not an array) * * @example * ```typescript * if (isStandardRecord(data)) { * // TypeScript now knows data is Record<string, unknown> * console.log(data.someProperty); * } * ``` */ export function isStandardRecord(value) { return typeof value === "object" && value !== null && !Array.isArray(value); } /** * Type guard for checking if value is a JsonRecord */ export function isJsonRecord(value) { return (isStandardRecord(value) && Object.values(value).every((val) => val === null || typeof val === "string" || typeof val === "number" || typeof val === "boolean" || Array.isArray(val) || isJsonRecord(val))); } /** * Type guard for checking if value is a StringArray */ export function isStringArray(value) { return (Array.isArray(value) && value.every((item) => typeof item === "string")); } /** * Type guard for checking if value is an AsyncFunction */ export function isAsyncFunction(value) { return typeof value === "function"; }