import type { ExactReturn, OptionalArgIfUndefined } from "./types.js"; import { AsyncMapperSchemaValue, AsyncObjectMapperFunction, AsyncObjectMapperSchema } from "./async-types.js"; /** * Convert from one type of object to another. * * Instantiate an instance with a {@linkcode AsyncObjectMapperSchema}. You must pass two type parameters: * * - `TInput`: the type of the input object * - `TOutput`: the type of the desired output object * * You can pass an optional third type parameter: * * - `TContext`: an object with any additional data or functions. Useful when mapping multiple * objects with some shared state, like a "now" timestamp. * * Invoke the mapper with {@linkcode AsyncObjectMapper#map}. * * If you want a plain (unbound) function, you can call {@linkcode AsyncObjectMapper#toFunction}. * * There is a convenience method {@linkcode AsyncObjectMapper#array}, for mapping some iterable to an array. * * @group async */ export declare class AsyncObjectMapper { /** * Defines how to populate property on the output type. */ readonly schema: AsyncObjectMapperSchema; /** * Create an AsyncObjectMapper factory function. Invoke it immediately, * with an object mapper schema, to create an AsyncObjectMapper instance. * * We use this approach to trick TypeScript into requiring an exact type * to be passed in. That is, the object mapper schema must only have * properties that exist in the output type, and no additional properties. */ static create(): & { [P in Exclude]: never; }>(schema: TActualSchema) => AsyncObjectMapper; /** * For faster runtime performance, the object mapper schema is converted to * a Map instance. * @private */ protected readonly schemaMap: Map>; protected constructor( /** * Defines how to populate property on the output type. */ schema: AsyncObjectMapperSchema); /** * Map multiple input objects from some iterable, and return an * array of output objects. */ array(input: Iterable, context: OptionalArgIfUndefined): Promise>; /** * Map multiple input objects from some iterable, and return an * array of output objects. * * If the input is `null`, it will be returned as-is. */ array(input: Iterable | null, context: OptionalArgIfUndefined): Promise | null>; /** * Map multiple input objects from some iterable, and return an * array of output objects. * * If the input is `undefined`, it will be returned as-is. */ array(input: Iterable | undefined, context: OptionalArgIfUndefined): Promise | undefined>; /** * Map multiple input objects from some iterable, and return an * array of output objects. * * If the input is `null` or `undefined`, it will be returned as-is. */ array(input: Iterable | null | undefined, context: OptionalArgIfUndefined): Promise | null | undefined>; /** * Maps an input object to an output object. * * It does so by iterating each property in the object schema, * and invoking the property's mapping function, passing the input and context. */ map(input: TInput, context: OptionalArgIfUndefined): Promise>; /** * Maps an input object to an output object. * * It does so by iterating each property in the object schema, * and invoking the property's mapping function, passing the input and context. * * If {@linkcode input} is `null`, it will be returned as-is. */ map(input: TInput | null, context: OptionalArgIfUndefined): Promise | null>; /** * Maps an input object to an output object. * * It does so by iterating each property in the object schema, * and invoking the property's mapping function, passing the input and context. * * If {@linkcode input} is `undefined`, it will be returned as-is. */ map(input: TInput | undefined, context: OptionalArgIfUndefined): Promise | undefined>; /** * Maps an input object to an output object. * * It does so by iterating each property in the object schema, * and invoking the property's mapping function, passing the input and context. * * If {@linkcode input} is `null` or `undefined`, it will be returned as-is. */ map(input: TInput | null | undefined, context: OptionalArgIfUndefined): Promise | null | undefined>; /** * Wrap this instance in a function, with a `schema` property. */ toFunction(): AsyncObjectMapperFunction; } //# sourceMappingURL=async-object-mapper.d.ts.map