UNPKG

@cowwoc/requirements

Version:

A fluent API for enforcing design contracts with automatic message generation.

77 lines (76 loc) 2.5 kB
import { Type, type StringMapper } from "./internal.mjs"; /** * Returns the String representation of an object. */ declare class StringMappers { /** * The default mapper configuration. */ static readonly DEFAULT: StringMappers; readonly typeToMapper: Map<Type, StringMapper>; /** * Creates a new instance. If `typeToMapper` is `undefined` the new instance uses the * default mappings. Otherwise, it contains a copy of the `typeToMapper` mappings. * * @param typeToMapper - a mapping from the name of a type to the string representation of its values * @throws TypeError if `typeToMapper` is `undefined` or `null` */ constructor(typeToMapper?: Map<Type, StringMapper>); /** * @param array - an array * @param seen - the objects that we've seen before * @returns the "deep" String representation of the array */ private arrayToString; /** * Returns the string representation of a value using the mappers. * * @param value - a value * @param seen - the objects that we've seen before * @returns the string representation of the value */ private valueToString; /** * @param set - a Set of elements * @param seen - the objects that we've seen before * @returns the string representation of the set */ private setToString; /** * @param list - an ordered list of values * @param seen - the objects that we've seen before * @returns the string representation of `list` */ private orderedToString; /** * @param map - a Map of elements * @param seen - the objects that we've seen before * @returns the String representation of the map */ private mapToString; /** * @param entries - map entries * @param seen - the objects that we've seen before * @returns the String representation of the entries */ private mapEntriesToString; /** * @param error - an `Error` * @returns the string representation of the error */ private errorToString; /** * Returns the string representation of the mappers. * * @returns the string representation of the mappers */ toString(): string; /** * Returns the string representation of a value using the mappers. * * @param value - a value * @returns the string representation of the value */ toString(value: unknown): string; } export { StringMappers };