import { Guard, Awaitable, Falsy } from '@mvdlei/types'; import { z } from 'zod'; /** * Interface for the `is` property of `T` */ interface IIs { /** * Check if a value is a string */ string: Guard; /** * Check if a value is a number */ number: Guard; /** * Check if a value is null */ null: Guard; /** * Check if a value is undefined */ undefined: Guard; /** * Check if a value is a boolean */ boolean: Guard; /** * Check if a value is a bigint */ bigint: Guard; /** * Check if a value is a symbol */ symbol: Guard; /** * Check if a value is an object */ object: Guard; /** * Check if a value is a function */ function: Guard<(() => unknown) | Function | (() => Awaitable)>; /** * Check if a value is any */ any: Guard; /** * Check if a value is an array */ array: Guard; /** * Check if a value is a date */ date: Guard; /** * Check if a value is an error */ error: Guard; /** * Check if a value is a promise, please note that this is not for async functions that do not return a promise. */ promise: Guard>; /** * Check if a value is falsy */ falsy: Guard; /** * Check if a value is a zod schema * */ schema: (c: C, v: unknown) => v is C; /** * Because of the way `instanceof` works, you are required to pass the class or Object as second argument. * The first argument is a class or object instance you want to check against. * * Make sure to use the `new` keyword when using this function. otherewise you will check against the class itself and not the instance, so the result will not be as expected. * * @param c - The class or object instance you want to check against * @param v - The value you want to check * @returns * - `true` if the value is an instance of the class * - `false` if the value is not an instance of the class */ instanceof: (c: new (...args: any[]) => C, v: unknown) => v is C; /** * Check if a value is of a certain type with a predicate function * @param v value to check * @param f predicate function * @returns `true` if the value is of the type * @returns `false` if the value is not of the type */ of: (v: V, f: (v: V) => v is C) => boolean; /** * Check if the current environment is the browser or not. * * Uses `typeof window === "undefined"` as check. */ server: () => boolean; /** * Check if the current environment is the browser or not. * * Uses `typeof window !== "undefined"` as check. */ browser: () => boolean; } declare class Is implements IIs { string(value: unknown): value is string; number(value: unknown): value is number; null(value: unknown): value is null; undefined(value: unknown): value is undefined; boolean(value: unknown): value is boolean; bigint(value: unknown): value is bigint; symbol(value: unknown): value is symbol; object(value: unknown): value is object; array(value: unknown): value is unknown[]; function(value: unknown): value is ((...args: unknown[]) => unknown) | Function; any(value: unknown): value is any; date(value: unknown): value is Date; error(value: unknown): value is Error; promise(value: unknown): value is Awaitable; schema: (c: C, v: unknown) => v is C; instanceof: (c: new (...args: any[]) => C, v: unknown) => v is C; of: (v: V, f: (v: V) => v is C) => v is C; falsy(value: unknown): value is Falsy; server(): boolean; browser(): boolean; } export { type IIs, Is };