Loxer - v3.0.0
    Preparing search index...

    Class PropsPrinter

    A helper class that renders the props of a Lox into a readable string.

    The built-in console output uses it for every log whose call chained Loxer.printProps(...) / Loxer.pp(...). An output stream receives the raw lox inside its discriminated event and reaches the same rendering through PropsPrinter.of:

    output: (event) => {
    if (event.kind === 'log' && event.lox.printProps) {
    console.log(event.lox.message + PropsPrinter.of(event.lox).print());
    }
    }
    Index
    • renders a Lox' props - similar to what the console methods do, but with some improvements:

      • the depth of objects / arrays is not bound to 3
      • the indent is configurable
      • indent is shown with vertical indicator lines
      • objects can be filtered to specific keys (helpful when dealing with large props)

      Several props are listed one after another, in the order they were passed. A log without props renders the empty string.

      PropsPrinter.of(outputLox).print(true, {
      depth: outputLox.module.slicedName.length + BoxFactory.getMarkerDepth(outputLox.box),
      color: outputLox.module.color,
      })

      Parameters

      • colored: boolean = true

        should the output be colored (with ANSI colors)

      • Optionalbox: { depth?: number; color?: string }

        options for the box surrounding the printed props

        • Optionaldepth?: number

          the vertical depth, where the box starts / ends (typically the column of the log's box; capped at 200)

          • if left undefined the box will have a depth of 20 and is not connected to the surrounding box layout
        • Optionalcolor?: string

          color of the box and surrounding text (typically the color of the log's box)

          • if left undefined, the box will be grey

      Returns string

      a pretty string of the props

    • The static constructor of the PropsPrinter helper class. Use it for any OutputLox or ErrorLox:

      PropsPrinter.of(outputLox)
      

      The printer is configured from the lox' own Lox.printProps - the configuration the call chained onto Loxer.printProps(...). Whether to render at all stays the caller's decision: lox.printProps is undefined for a log that did not ask for it.

      Parameters

      • lox: Lox

        to render the props of

      Returns PropsPrinter

      a printer with a chained print(...) method

    • The static constructor for values that belong to no log.

      PropsPrinter.ofValues([payment, cart], { depth: 2 })
      

      Parameters

      • values: unknown[]

        to render, listed one after another

      • Optionaloptions: PropsPrinterOptions

        to configure the rendering

      Returns PropsPrinter

      a printer with a chained print(...) method

    • Renders a single value onto exactly one line, whatever its size.

      Loxer.log(payment) uses this for a non-primitive message: lox.message is a string, and a line break in it would corrupt the box column.

      Parameters

      • value: unknown

        to render

      Returns string

      a one-line, uncolored rendering of the value