import { Cast, CastSettings, TCastAll } from "./internal.js"; import { Collection, Primitive, SimpleType, SimpleTypeOf, Struct } from "./types.js"; export declare type TConvertMap = T extends SimpleType ? SimpleTypeOf : T extends Convert ? R : T extends { [k in keyof T]: any; } ? { [k in keyof T]: TConvertMap; } : unknown; export declare type TDeconsMap = T extends SimpleType ? T : T extends Date ? Date : { readonly [k in keyof T]: Convert; }; export declare class Convert extends Cast { private readonly _convert; constructor(_convert: (value: unknown, settings: CastSettings) => T); static lazy(fun: (s: CastSettings) => Convert): Convert; convert(value: unknown): T; convert(value: unknown, settings: CastSettings): T; decons(): TDeconsMap; config(config: Partial): Convert; static readonly id: Convert; static toConst(value: T): Convert; compose(g: Convert): Convert; map(fun: (value: T) => R): Convert; /** * Converts to a union of the given options, and defaults to the first option. * @param options an array of options to choose from, where the first option is the default * @returns a `Convert` that converts to a union */ static toEnum(...options: R): Convert; static toString(alt?: string): Convert; static toNumber(alt?: number): Convert; static toFinite(alt?: number): Convert; static toInteger(alt?: number): Convert; static toBoolean(alt?: boolean): Convert; static toTruthy(): Convert; static toBigInt(alt?: bigint): Convert; static toDate(alt?: Date): Convert; static get toJSON(): Convert; static toArray(alt?: unknown[]): Convert; static toArrayOf(convertItem: Convert, alt?: T[]): Convert; static toStructOf(convertItem: Convert, alt?: Struct): Convert>; /** * Given an object or tuple of converts, it produces a convert that outputs an object or tuple having the same shape as the given converts. * @param casts an object or tuple of converts * @returns a convert that produces an object or tuple matching the shape of the given converts */ static toCollectionLike>(converts: T): Convert>; /** * Produces a convert that filters out values from the input that could not be casted by the given cast. * @param cast the cast to use for filtering * @returns a convert that filters out values that could not be casted by the given cast */ static toArrayWhere(cast: Cast): Convert; /** * Creates a `Convert` based on the given sample value, which is also used as the set of default values. * @param alt a sample value which also serves as the set of default values * @returns a `Convert` based on the given sample value */ static to(alt: T): Convert>; toEnum(...options: R): Convert; toString(alt?: string): Convert; toNumber(alt?: number): Convert; toBoolean(alt?: boolean): Convert; toBigInt(alt?: bigint): Convert; toDate(alt?: Date): Convert; toArray(convertItem: Convert, alt?: T[]): Convert; toArrayOf(convertItem: Convert, alt?: T[]): Convert; toStructOf(convertItem: Convert, alt?: Struct): Convert>; toCollectionLike>(converts: T): Convert>; toArrayWhere(cast: Cast): Convert; to(alt: T): Convert>; }