PropertyFormatter overview
This module implements a type that takes care of the stringification of the properties of a non-primitive value. From the stringified representation of the value of a property which it receives, it must return the stringified representation of the whole property (key and value).
With the make function, you can define your own instances if the provided ones don’t suit your needs.
Table of contents
Constructors
make
Constructor
Signature
export declare const make: ({ id, action }: { readonly id: string; readonly action: Action.Type }) => Type
Destructors
id
Returns the id
property of self
Signature
export declare const id: MTypes.OneArgFunction<Type, string>
Equivalences
equivalence
PropertyFormatter equivalence
Signature
export declare const equivalence: Equivalence.Equivalence<Type>
Guards
has
Type guard
Signature
export declare const has: (u: unknown) => u is Type
Instances
keyAndValue
PropertyFormatter instance that prints the key and value of a property (similar to the usual way a record is printed). A mark can be prepended or appended to the key to show if the property comes from the object itself or from one of its prototypes.
Signature
export declare const keyAndValue: Type
treeify
PropertyFormatter instance that :
- For a leaf: does the same as keyAndValue
- For a non-leaf: prints the key and value on separate lines without any key/value separator
Signature
export declare const treeify: Type
treeifyHideLeafValues
PropertyFormatter instance that :
- For a leaf: prints only the key
- For a non-leaf: prints the key and value on separate lines without any key/value separator
Signature
export declare const treeifyHideLeafValues: Type
valueOnly
PropertyFormatter instance that prints only the value of a property (similar to the usual way an array is printed).
Signature
export declare const valueOnly: Type
Models
Action (namespace)
Namespace of a PropertyFormatter used as an action
Type (interface)
Type of the action. The action takes as input a ValueBasedStylerConstructor (see ValueBasedStylerConstructor.ts), a MarkShowerConstructor (see MarkShowerConstructor.ts). Based on these two parameters, it must return an Initialized Action.
Signature
export interface Type {
(
this: PPOption.NonPrimitive.Type,
{
valueBasedStylerConstructor,
markShowerConstructor
}: {
readonly valueBasedStylerConstructor: PPValueBasedStylerConstructor.Type
readonly markShowerConstructor: PPMarkShowerConstructor.Type
}
): Initialized.Type
}
Initialized (namespace)
Namespace of an initialized PropertyFormatter used as an action
Type (interface)
Type of the action. The action takes as input the Value (see Value.ts) being currently printed, a boolean that indicates if the value is a leaf (i.e. it could be stringified without stringifying each of its properties) and the stringified representation of that value (see StringifiedValue.ts) . Based on these two parameters, it must return a stringified representation of the whole property.
Signature
export interface Type {
({
value,
isLeaf
}: {
readonly value: PPValue.All
readonly isLeaf: boolean
}): MTypes.OneArgFunction<PPStringifiedValue.Type>
}
Type (interface)
Type that represents a PropertyFormatter.
Signature
export interface Type extends Action.Type, Equal.Equal, MInspectable.Inspectable, Pipeable.Pipeable {
/** Id of this PropertyFormatter instance. Useful for equality and debugging */
readonly id: string
/** @internal */
readonly [_TypeId]: _TypeId
}
moduleTag
Module tag
Signature
export declare const moduleTag: "@parischap/pretty-print/PropertyFormatter/"