UNPKG

@parischap/pretty-print

Version:
84 lines 2.37 kB
/** * This module implements a type that takes care of the formatting of primitive values, e.g. * surround strings in quotes, add 'n' at the end of a bigint, display numbers with a thousand * separator,... * * With the make function, you can define your own instances if the provided ones don't suit your * needs. */ import { MInspectable, MTypes } from '@parischap/effect-lib'; import { Equal, Equivalence, Pipeable } from 'effect'; import type * as PPOption from './Option.js'; import * as PPValue from './Value.js'; /** * Module tag * * @category Models */ export declare const moduleTag = "@parischap/pretty-print/PrimitiveFormatter/"; declare const _TypeId: unique symbol; type _TypeId = typeof _TypeId; /** * Namespace of a PrimitiveFormatter used as an action * * @category Models */ export declare namespace Action { /** * Type of the action of a PrimitiveFormatter. The action takes a Primitive value (see Value.ts) * and returns an unstyled string representing that value. */ interface Type { (this: PPOption.Type, value: PPValue.Primitive): string; } } /** * Type that represents a PrimitiveFormatter * * @category Models */ export interface Type extends Action.Type, Equal.Equal, MInspectable.Inspectable, Pipeable.Pipeable { /** Id of this PrimitiveFormatter instance. Useful for equality and debugging */ readonly id: string; /** @internal */ readonly [_TypeId]: _TypeId; } /** * Type guard * * @category Guards */ export declare const has: (u: unknown) => u is Type; /** * Equivalence * * @category Equivalences */ export declare const equivalence: Equivalence.Equivalence<Type>; /** * Constructor * * @category Constructors */ export declare const make: ({ id, action }: { readonly id: string; readonly action: Action.Type; }) => Type; /** * Returns the `id` property of `self` * * @category Destructors */ export declare const id: MTypes.OneArgFunction<Type, string>; /** * PropertyFormatter contructor that builds an instance that works like util.inspect * * @category Constructors */ export declare const utilInspectLikeMaker: ({ id, maxStringLength, numberFormatter }?: { readonly id: string; readonly maxStringLength: number; readonly numberFormatter: Intl.NumberFormat; }) => Type; export {}; //# sourceMappingURL=PrimitiveFormatter.d.ts.map