//#region src/typeGuards.d.ts /** * Type guard to check if a value is a plain object (not null, not an array). * * Returns true if the value is an object that is not null and not an array. * This is useful for distinguishing between objects and other types. * * @example * ```typescript * if (isObject(value)) { * // TypeScript knows value is Record * console.log(value.someProperty); * } * * isObject({}); // true * isObject({ a: 1 }); // true * isObject(null); // false * isObject([]); // false * isObject('string'); // false * ```; * * @param value - The value to check * @returns True if the value is a plain object, false otherwise */ declare function isObject(value: unknown): value is Record; /** * Type guard to check if a value is a function. * * Returns true if the value is a function of any kind (regular function, arrow * function, method, constructor, etc.). * * @example * ```typescript * if (isFunction(value)) { * // TypeScript knows value is (...args: any[]) => any * const result = value(); * } * * isFunction(() => {}); // true * isFunction(function() {}); // true * isFunction(Math.max); // true * isFunction('string'); // false * isFunction({}); // false * ```; * * @param value - The value to check * @returns True if the value is a function, false otherwise */ declare function isFunction(value: unknown): value is (...args: any[]) => any; /** * Type guard to check if a value is a Promise or thenable object. * * Returns true if the value is an object with a `then` method that is a * function. This covers both native Promises and thenable objects that * implement the Promise interface. * * @example * ```typescript * if (isPromise(value)) { * // TypeScript knows value is Promise * const result = await value; * } * * isPromise(Promise.resolve()); // true * isPromise(new Promise(() => {})); // true * isPromise({ then: () => {} }); // true * isPromise({ then: 'not a function' }); // false * isPromise('string'); // false * ```; * * @param value - The value to check * @returns True if the value is a Promise or thenable, false otherwise */ declare function isPromise(value: unknown): value is Promise; /** * Type guard to check if a value is a plain object (created by Object literal * or Object constructor). * * Returns true if the value is a plain object - an object created by the Object * constructor or object literal syntax. This excludes instances of classes, * built-in objects like Date, RegExp, etc. * * @example * ```typescript * if (isPlainObject(value)) { * // TypeScript knows value is Record * console.log(Object.keys(value)); * } * * isPlainObject({}); // true * isPlainObject({ a: 1 }); // true * isPlainObject(Object.create(null)); // true * isPlainObject(new Date()); // false * isPlainObject(/regex/); // false * isPlainObject(new MyClass()); // false * isPlainObject([]); // false * ```; * * @param value - The value to check * @returns True if the value is a plain object, false otherwise */ declare function isPlainObject(value: any): value is Record; type NonEmptyArray = [T, ...T[]]; declare function isNonEmptyArray(value: T[] | readonly T[]): value is NonEmptyArray; declare function arrayHasAtLeastXItems(array: T[], minLength: 1): array is [T, ...T[]]; declare function arrayHasAtLeastXItems(array: T[], minLength: 2): array is [T, T, ...T[]]; declare function arrayHasAtLeastXItems(array: T[], minLength: 3): array is [T, T, T, ...T[]]; declare function arrayHasAtLeastXItems(array: T[], minLength: 4): array is [T, T, T, T, ...T[]]; declare function arrayHasAtLeastXItems(array: T[], minLength: 5): array is [T, T, T, T, T, ...T[]]; declare function isTruthy(value: T): value is Exclude; //#endregion export { NonEmptyArray, arrayHasAtLeastXItems, isFunction, isNonEmptyArray, isObject, isPlainObject, isPromise, isTruthy };