Skip to main content Link Search Menu Expand Document (external link)

Value overview

Type that represents a value in its stringification context.

This module provides several Order instances to sort Value’s according to your needs


Table of contents


Constructors

fromIterable

Constructor from a value extracted from an iterable non-primitive value

Signature

export declare const fromIterable: <V>({
  content,
  stringKey,
  depth
}: {
  readonly content: V
  readonly stringKey: MTypes.OverOne<string>
  readonly depth: number
}) => Type<V>

fromNonPrimitiveValueAndKey

Constructor from the property of a non-primitive value

Signature

export declare const fromNonPrimitiveValueAndKey: ({
  nonPrimitiveContent,
  key,
  depth,
  protoDepth
}: {
  readonly nonPrimitiveContent: MTypes.NonPrimitive
  readonly key: string | symbol
  readonly depth: number
  readonly protoDepth: number
}) => All

fromTopValue

Constructor from the top value to stringify

Signature

export declare const fromTopValue: <V>(content: V) => Type<V>

Destructors

content

Returns the content property of self

Signature

export declare const content: <V>(self: Type<V>) => V

contentType

Returns the contentType property of self

Signature

export declare const contentType: MTypes.OneArgFunction<All, MTypes.Category.Type>

depth

Returns the depth property of self

Signature

export declare const depth: MTypes.OneArgFunction<All, number>

hasSymbolicKey

Returns the hasSymbolicKey property of self

Signature

export declare const hasSymbolicKey: MTypes.OneArgFunction<All, boolean>

isEnumerable

Returns the isEnumerable property of self

Signature

export declare const isEnumerable: MTypes.OneArgFunction<All, boolean>

oneLineStringKey

Returns the oneLineStringKey property of self

Signature

export declare const oneLineStringKey: MTypes.OneArgFunction<All, string>

protoDepth

Returns the protoDepth property of self

Signature

export declare const protoDepth: MTypes.OneArgFunction<All, number>

stringKey

Returns the stringKey property of self

Signature

export declare const stringKey: MTypes.OneArgFunction<All, MTypes.OverOne<string>>

Equivalences

equivalence

Value equivalence based on strict equality of the content properties. Used for cycle detection

Signature

export declare const equivalence: Equivalence.Equivalence<All>

Guards

has

Type guard

Signature

export declare const has: (u: unknown) => u is All

isFunction

Type guard

Signature

export declare const isFunction: (u: All) => u is Type<MTypes.AnyFunction>

isNonPrimitive

Type guard

Signature

export declare const isNonPrimitive: (u: All) => u is NonPrimitive

isPrimitive

Type guard

Signature

export declare const isPrimitive: (u: All) => u is Primitive

Models

All (interface)

Type that represents any value in its stringification context

Signature

export interface All extends Type<unknown> {}

NonPrimitive (interface)

Type that represents a non-primitive value in its stringification context

Signature

export interface NonPrimitive extends Type<MTypes.NonPrimitive> {}

Primitive (interface)

Type that represents a primitive value in its stringification context

Signature

export interface Primitive extends Type<MTypes.Primitive> {}

Type (interface)

Type of a Value

Signature

export interface Type<out V> extends Equal.Equal, Inspectable.Inspectable, Pipeable.Pipeable {
  /** The value */
  readonly content: V

  /** Type of content */
  readonly contentType: MTypes.Category.Type

  /**
   * Depth of this value in the value to stringify: number of nested non-primitive values to open to
   * reach this value.
   */
  readonly depth: number

  /** Depth of this value in the prototypal chain of a non-primitive value */
  readonly protoDepth: number

  /**
   * Array of strings representing the key associated to that value if any. If this value is not in
   * a non-primitive value, i.e. it is itself the value to stringify, `stringKey` is an array
   * containing an empty string. If it is the value of one of the properties of a non-primitive
   * value, `stringKey` is a one-element array containing the property key converted to a string. If
   * it is one of the values of an iterable non-primitive value (e.g. a Map), `stringKey` is the
   * unstyled stringified key associated to the value.
   */
  readonly stringKey: MTypes.OverOne<string>

  /** Same as stringKey, but all lines are joined with an empty string */
  readonly oneLineStringKey: string

  /**
   * `true` if this value is the value of one of the properties of a non-primitive value whose
   * associated property key is a symbol. `false` otherwise.
   */
  readonly hasSymbolicKey: boolean

  /**
   * `true` if this value is the value of one of the properties of a non-primitive value that is
   * enumerable. `false` otherwise.
   */
  readonly isEnumerable: boolean

  /** @internal */
  readonly [_TypeId]: {
    readonly _V: Types.Covariant<V>
  }
}

moduleTag

Module tag

Signature

export declare const moduleTag: "@parischap/pretty-print/Value/"