UNPKG

typizator

Version:

Runtime types and metadata schemas for Typescript

18 lines (17 loc) 1.07 kB
import { ObjectOrFacadeS, SchemaDefinition } from "./schemas"; import { SchemaTarget } from "./type-conversions"; /** * Transforms a string to an array of objects containing a string for each column * @param source Source multiline string, first line is a list of field names, the following ones, list of records * @param defaults Default values to add to each record if there are no corresponding values in the input string * @returns Array of objects */ export declare const transformToArray: <T extends SchemaDefinition>(source: string, defaults?: Partial<SchemaTarget<T>>) => Object[]; /** * Transforms a multiline input string to a well-typed object * @param schema Schema defining the object's types * @param source Source string * @param defaults Default values to add to each record if there are no corresponding values in the input string * @returns Array of well-typed objects */ export declare const tabularInput: <T extends SchemaDefinition>(schema: ObjectOrFacadeS<T>, source: string, defaults?: Partial<SchemaTarget<T>>) => SchemaTarget<T>[];