@parischap/pretty-print
Version:
A functional library to pretty-print and treeify objects
114 lines • 4.02 kB
TypeScript
/**
* 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.
*/
import { MInspectable, MTypes } from '@parischap/effect-lib';
import { Equal, Equivalence, Option, Pipeable } from 'effect';
import * as PPMarkShowerConstructor from './MarkShowerConstructor.js';
import type * as PPOption from './Option.js';
import * as PPStringifiedValue from './StringifiedValue.js';
import * as PPValue from './Value.js';
import * as PPValueBasedStylerConstructor from './ValueBasedStylerConstructor.js';
/**
* Module tag
*
* @category Models
*/
export declare const moduleTag = "@parischap/pretty-print/ByPasser/";
declare const _TypeId: unique symbol;
type _TypeId = typeof _TypeId;
/**
* Namespace of a ByPasser used as an action
*
* @category Models
*/
export declare namespace Action {
/**
* 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.
*
* @category Models
*/
interface Type {
(this: PPOption.Type, { valueBasedStylerConstructor, markShowerConstructor }: {
readonly valueBasedStylerConstructor: PPValueBasedStylerConstructor.Type;
readonly markShowerConstructor: PPMarkShowerConstructor.Type;
}): MTypes.OneArgFunction<PPValue.All, Option.Option<PPStringifiedValue.Type>>;
}
}
/**
* Type that represents a ByPasser.
*
* @category Models
*/
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;
}
/**
* 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>;
/**
* ByPasser instance that does not bypass any value
*
* @category Instances
*/
export declare const empty: Type;
/**
* 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`
*
* @category Instances
*/
export declare const functionToName: Type;
/**
* 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 a `none` otherwise. Calling the .toString method on an Iterable will not
* be as efficient as using the `FromValueIterable` or `FromKeyValueIterable` property sources.
* Calling the .toString method on a function will not work properly.
* - For any other value: returns a `none`
*
* @category Instances
*/
export declare const objectToString: Type;
export {};
//# sourceMappingURL=ByPasser.d.ts.map