import { type FixDeepFunctionInfer, type NeverCoalescing } from "../../common"; import { type DataParser, type DataParserDefinition } from "../base"; import { type DataParserError, SymbolDataParserError } from "../../dataParser/error"; import { type DataParserChecker } from "../baseChecker"; import { type ApplyRefinementOfDefinition, type AddCheckersToDefinition, type GetEligibleChecker, type Input, type MergeDefinition, type Output, type PrepareDataParserDefinition } from "../types"; export type DataParserTransformCheckers = GetEligibleChecker; export interface DataParserDefinitionTransform extends DataParserDefinition> { readonly inner: DataParser; theFunction(input: any, error: DataParserError): GenericOutput; } export declare const transformKind: import("../../common").KindHandler>; export type DataParserTransformOutput = Exclude>, typeof SymbolDataParserError>; declare const DataParserTransform_base: import("..").DataParserBaseInit>>; export declare class DataParserTransform extends DataParserTransform_base, GenericDefinition>, ApplyRefinementOfDefinition, GenericDefinition>> { get classConstructor(): typeof DataParserTransform & import("..").CheckedConstructorKind; addChecker: >, ...DataParserChecker>[] ]>(...args: FixDeepFunctionInfer>, ...DataParserChecker>[] ], GenericChecker>) => DataParserTransform>; static execParse(self: DataParserTransform, data: unknown, error: DataParserError): unknown; static dataParserIsAsynchronous(self: DataParserTransform): boolean; static prepareDefinition(inner: DataParser, theFunction: (input: unknown, error: DataParserError) => unknown, definition?: Partial>): DataParserDefinitionTransform; /** * Creates a data parser that transforms the output of another parser. * * **Supported call styles:** * - Classic: `DP.transform(inner, theFunction, definition?)` -> returns a transform parser * - Curried: not available * * Runs the inner parser and applies a transformation function to its output. * * ```ts * const parser = DP.transform(DP.string(), (value) => value.length); * const result = parser.parse("Duplo"); * if (E.isRight(result)) { * const value = unwrap(result); * // value: number * } * * const toUpper = DP.transform( * DP.string(), * S.toUpperCase, * ); * const upperResult = toUpper.parse("duplo"); * ``` * * @see https://utils.duplojs.dev/en/v1/api/dataParser/transform * * @namespace DP * */ static create GenericOutput>>, "inner" | "theFunction"> = never>(inner: GenericDataParser, theFunction: (input: Output, error: DataParserError) => GenericOutput, definition?: FixDeepFunctionInfer GenericOutput>>, "inner" | "theFunction">, GenericDefinition>): DataParserTransform & { inner: GenericDataParser; theFunction(input: Output, error: DataParserError): GenericOutput; }>>; } /** * Creates a data parser that transforms the output of another parser. * * **Supported call styles:** * - Classic: `DP.transform(inner, theFunction, definition?)` -> returns a transform parser * - Curried: not available * * Runs the inner parser and applies a transformation function to its output. * * ```ts * const parser = DP.transform(DP.string(), (value) => value.length); * const result = parser.parse("Duplo"); * if (E.isRight(result)) { * const value = unwrap(result); * // value: number * } * * const toUpper = DP.transform( * DP.string(), * S.toUpperCase, * ); * const upperResult = toUpper.parse("duplo"); * ``` * * @see https://utils.duplojs.dev/en/v1/api/dataParser/transform * * @namespace DP * */ export declare const transform: typeof DataParserTransform.create; export {};