ByPasser overview
This module implements a type that defines a specific stringification process for certain values (the normal stringification process is by-passed, hence its name). For instance, you may prefer printing a Date as a string rather than as an object with all its technical properties.
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
Equivalence
Signature
export declare const equivalence: Equivalence.Equivalence<Type>
Guards
has
Type guard
Signature
export declare const has: (u: unknown) => u is Type
Instances
empty
ByPasser instance that does not bypass any value
Signature
export declare const empty: Type
functionToName
ByPasser instance that has the following behavior:
- For any function: a some of the function name surrounded by the function delimiters and the message delimiters. If the function name is an empty string,
anonymous
is used instead. - For any other value: returns a
none
Signature
export declare const functionToName: Type
objectToString
ByPasser instance that has the following behavior:
- For any non-primitive value which is not an iterable or a function : tries to call the toString method (only if it is different from Object.prototype.toString). Returns a
some
of the result if successful. Returns anone
otherwise. Calling the .toString method on an Iterable will not be as efficient as using theFromValueIterable
orFromKeyValueIterable
property sources. Calling the .toString method on a function will not work properly. - For any other value: returns a
none
Signature
export declare const objectToString: Type
Models
Action (namespace)
Namespace of a ByPasser used as an action
Type (interface)
Type of the action. The action takes as input a ValueBasedStylerConstructor (see ValueBasedStylerConstructor.ts), a MarkShowerConstructor (see Option.ts) and the Value being currently printed. If the action returns a value of type Some<StringifiedValue.Type>
, this StringifiedValue
will be used as is to represent the input value. If it returns a none
, the normal stringification process will be applied.
Signature
export interface Type {
(
this: PPOption.Type,
{
valueBasedStylerConstructor,
markShowerConstructor
}: {
readonly valueBasedStylerConstructor: PPValueBasedStylerConstructor.Type
readonly markShowerConstructor: PPMarkShowerConstructor.Type
}
): MTypes.OneArgFunction<PPValue.All, Option.Option<PPStringifiedValue.Type>>
}
Type (interface)
Type that represents a ByPasser.
Signature
export interface Type extends Action.Type, Equal.Equal, MInspectable.Inspectable, Pipeable.Pipeable {
/** Id of this ByPasser instance. Useful for equality and debugging */
readonly id: string
/** @internal */
readonly [_TypeId]: _TypeId
}
moduleTag
Module tag
Signature
export declare const moduleTag: "@parischap/pretty-print/ByPasser/"