UNPKG

honestjs

Version:

HonestJS - a modern web framework built on top of Hono

117 lines (116 loc) 3.77 kB
/** * Type guard that checks if a value is undefined * @param obj - The value to check * @returns True if the value is undefined, false otherwise */ export declare const isUndefined: (obj: unknown) => obj is undefined; /** * Type guard that checks if a value is null or undefined * @param val - The value to check * @returns True if the value is null or undefined, false otherwise */ export declare const isNil: (val: unknown) => val is null | undefined; /** * Type guard that checks if a value is an object (excluding null) * @param val - The value to check * @returns True if the value is a non-null object, false otherwise */ export declare const isObject: (val: unknown) => val is Record<PropertyKey, unknown>; /** * Type guard that checks if a value is a plain object (not a class instance or array) * Determines if an object is a simple key-value store created by object literals * * @param val - The value to check * @returns True if the value is a plain object, false otherwise * @example * ```ts * isPlainObject({}) // true * isPlainObject(new Class()) // false * isPlainObject([]) // false * ``` */ export declare const isPlainObject: (val: unknown) => val is Record<string, unknown>; /** * Type guard that checks if a value is a function * @param val - The value to check * @returns True if the value is a function, false otherwise */ export declare const isFunction: (val: unknown) => val is Function; /** * Type guard that checks if a value is a string * @param val - The value to check * @returns True if the value is a string, false otherwise */ export declare const isString: (val: unknown) => val is string; /** * Type guard that checks if a value is a number * @param val - The value to check * @returns True if the value is a number, false otherwise */ export declare const isNumber: (val: unknown) => val is number; /** * Checks if an array is empty * @param array - The array to check * @returns True if the array has no elements, false otherwise */ export declare const isEmpty: (array: unknown[]) => boolean; /** * Type guard that checks if a value is a symbol * @param val - The value to check * @returns True if the value is a symbol, false otherwise */ export declare const isSymbol: (val: unknown) => val is symbol; /** * Ensures a path starts with a leading slash * @param path - The path to process * @returns The path with a leading slash, or empty string if path is undefined * @example * ```ts * addLeadingSlash('test') // '/test' * addLeadingSlash('/test') // '/test' * ``` */ export declare const addLeadingSlash: (path?: string) => string; /** * Normalizes a path by ensuring: * - Starts with a single slash * - No trailing slashes * - No consecutive slashes * * @param path - The path to normalize * @returns The normalized path * @example * ```ts * normalizePath('//test//') // '/test' * normalizePath('test/path//') // '/test/path' * ``` */ export declare const normalizePath: (path?: string) => string; /** * Removes the trailing slash from a path * @param path - The path to process * @returns The path without a trailing slash * @example * ```ts * stripEndSlash('/test/') // '/test' * stripEndSlash('/test') // '/test' * ``` */ export declare const stripEndSlash: (path: string) => string; /** * Checks if a value is a constructor function * A constructor function must: * - Be a function * - Have a prototype * - Have prototype properties beyond the default ones * * @param val - The value to check * @returns True if the value is a constructor function, false otherwise * @example * ```ts * class Test {} * isConstructor(Test) // true * isConstructor(() => {}) // false * ``` */ export declare const isConstructor: (val: unknown) => boolean;