Parameters overview
This module implements the top-level parameters that configure the stringification process. A PPParameters instance bundles together a PPStyleMap, a PPPrimitiveFormatter, and one or more PPNonPrimitiveParameters instances, plus global settings that govern depth limits, circular-reference marks, and property-count formatting.
Use the make function to define custom instances if the pre-built ones do not suit your needs.
Table of contents
- Constructors
- Equivalences
- Getters
- Instances
- Models
- Type (class)
- make (static method)
- [MData.idSymbol] (method)
- [Hash.symbol] (method)
- [MEquivalenceBasedEqualityData.isEquivalentToSymbol] (method)
- [MEquivalenceBasedEqualityData.hasSameTypeMarkerAsSymbol] (method)
- id (property)
- styleMap (property)
- primitiveFormatter (property)
- nonPrimitiveParametersArray (property)
- name (property)
- maxDepth (property)
- openingTagMark (property)
- closingTagMark (property)
- circularReferenceTag (property)
- circularAnchorOpeningMark (property)
- circularAnchorClosingMark (property)
- headerSeparatorMark (property)
- propertyNumberSeparatorMark (property)
- propertyNumberOpeningMark (property)
- propertyNumberClosingMark (property)
- Type (class)
- Module markers
Constructors
make
Constructor of a PPParameters
Signature
export declare const make: (params: MTypes.Data<Type>) => Type
Equivalences
equivalence
Equivalence
Signature
export declare const equivalence: Equivalence.Equivalence<Type>
Getters
id
Returns the id property of self
Signature
export declare const id: MTypes.OneArgFunction<Type, string>
styleMap
Returns the styleMap property of self
Signature
export declare const styleMap: MTypes.OneArgFunction<Type, PPStyleMap.Type>
Instances
darkModeTreeify
PPParameters instance that renders a value as a tree with colors adapted to dark-mode terminals
Signature
export declare const darkModeTreeify: Type
darkModeTreeifyHideLeaves
PPParameters instance that renders a value as a tree with hidden leaf values, using colors adapted to dark-mode terminals
Signature
export declare const darkModeTreeifyHideLeaves: Type
darkModeUtilInspectLike
PPParameters instance that pretty-prints a value in a way very similar to util.inspect with colors adapted to a terminal in dark mode.
Signature
export declare const darkModeUtilInspectLike: Type
treeify
PPParameters instance that renders a value as a tree (without color styling)
Signature
export declare const treeify: Type
treeifyHideLeaves
PPParameters instance that renders a value as a tree and hides leaf values (only keys are shown), useful for inspecting an object’s shape
Signature
export declare const treeifyHideLeaves: Type
utilInspectLike
PPParameters instance that pretty-prints a value in a style very similar to util.inspect, without any color styling
Signature
export declare const utilInspectLike: Type
Models
Type (class)
Type that represents a PPParameters
Signature
export declare class Type {
private constructor({
id,
styleMap,
primitiveFormatter,
nonPrimitiveParametersArray,
name,
maxDepth,
openingTagMark,
closingTagMark,
circularReferenceTag,
circularAnchorOpeningMark,
circularAnchorClosingMark,
headerSeparatorMark,
propertyNumberSeparatorMark,
propertyNumberOpeningMark,
propertyNumberClosingMark
}: MTypes.Data<Type>)
}
make (static method)
Static constructor
Signature
static make(params: MTypes.Data<Type>): Type
[MData.idSymbol] (method)
Returns the id of this
Signature
[MData.idSymbol](): string | (() => string)
[Hash.symbol] (method)
Calculates the hash value of this
Signature
[Hash.symbol](): number
[MEquivalenceBasedEqualityData.isEquivalentToSymbol] (method)
Function that implements the equivalence of this and that
Signature
[MEquivalenceBasedEqualityData.isEquivalentToSymbol](this: this, that: this): boolean
[MEquivalenceBasedEqualityData.hasSameTypeMarkerAsSymbol] (method)
Predicate that returns true if that has the same type marker as this
Signature
[MEquivalenceBasedEqualityData.hasSameTypeMarkerAsSymbol](that: unknown): boolean
id (property)
Id of this. Useful for equality and debugging
Signature
readonly id: string
styleMap (property)
The PPStyleMap that assigns a style to each visual element of the output
Signature
readonly styleMap: PPStyleMap.Type
primitiveFormatter (property)
The PPPrimitiveFormatter used to convert primitive values to their string representation
Signature
readonly primitiveFormatter: PPPrimitiveFormatter.Type
nonPrimitiveParametersArray (property)
Non-empty array of PPNonPrimitiveParameters. When a non-primitive value is encountered, every entry whose isApplicableTo predicate returns true is selected and the matching entries are merged into a single fully-resolved set of parameters; lower-index entries override higher-index ones, and any field not specified by any matching entry falls back to the module- level default in PPNonPrimitiveParameters.defaultParams. Elements should therefore be ordered in decreasing specificity.
Signature
readonly nonPrimitiveParametersArray: [PPNonPrimitiveParameters.Type, ...PPNonPrimitiveParameters.Type[]]
name (property)
Function that derives the display name from any non-primitive value. The name is shown in two places:
- Surrounded by
openingTagMark/closingTagMarkwhenmaxDepthis exceeded (e.g.[Array],[Function: foo]). - In the header before the properties when the applicable
PPNonPrimitiveParameters.showNameistrue(e.g. theMapinMap(2) { 'a' => 1, 'b' => 2 }).
The default implementation returns 'Function: <name>' (or 'Function: (anonymous)') for functions, then tries Effect’s toJSON()._id convention, then falls back to value.constructor.name. This transparently covers Map, Set, WeakMap, WeakSet, all typed arrays, and user-defined classes.
Signature
readonly name: (nonPrimitive: MTypes.ReadonlyNonPrimitive) => string
maxDepth (property)
Maximum number of nested non-primitive values that will be opened. A value of 0 or less means that only the value to stringify is shown if it is primitive; if it is non-primitive it is replaced by a tag that depends on its type (e.g. [Object], [Array]). Pass +Infinity to expand all levels.
Signature
readonly maxDepth: number
openingTagMark (property)
Mark prepended to tags — both the header tag shown when maxDepth is exceeded and the circular-reference tag
Signature
readonly openingTagMark: string
closingTagMark (property)
Mark appended to tags — both the header tag shown when maxDepth is exceeded and the circular- reference tag
Signature
readonly closingTagMark: string
circularReferenceTag (property)
Text inserted in place of a non-primitive value that has already appeared higher up in the output tree, indicating a circular reference (e.g. Circular *1)
Signature
readonly circularReferenceTag: string
circularAnchorOpeningMark (property)
Mark prepended to the representation of a non-primitive value that is referenced again deeper in the tree (e.g. <Ref *1>)
Signature
readonly circularAnchorOpeningMark: string
circularAnchorClosingMark (property)
Mark appended to the representation of a non-primitive value that is referenced again deeper in the tree
Signature
readonly circularAnchorClosingMark: string
headerSeparatorMark (property)
Separator inserted between the header of a non-primitive value and the opening bracket of its properties (e.g. the space in Map(2) { 'a' => 1 })
Signature
readonly headerSeparatorMark: string
propertyNumberSeparatorMark (property)
Separator used between the two property counts inside the header (e.g. the , in Map(5,2) { … }), applicable when propertyNumberDisplayOption is AllAndActual or AllAndActualIfDifferent
Signature
readonly propertyNumberSeparatorMark: string
propertyNumberOpeningMark (property)
Mark placed before the property count(s) in the header (e.g. the ( in Map(2) { … }), applicable when propertyNumberDisplayOption is not None
Signature
readonly propertyNumberOpeningMark: string
propertyNumberClosingMark (property)
Mark placed after the property count(s) in the header (e.g. the ) in Map(2) { … }), applicable when propertyNumberDisplayOption is not None
Signature
readonly propertyNumberClosingMark: string
Module markers
moduleTag
Module tag
Signature
export declare const moduleTag: "@parischap/pretty-print/Parameters/"