Options
All
  • Public
  • Public/Protected
  • All
Menu

Module "xform/format"

Index

Functions

Const formatJSON

Const formatObject

Const formatString

Const isoDate

  • isoDate(dt: number): string

Const maskSecrets

  • maskSecrets(patterns: RegExp[], mask?: string): Transducer<string, string>
  • Takes an array of regex patterns and optional mask string. Returns transducer which replaces all found pattern occurrences with mask. Intended to be used in combination / after formatString to avoid leaking of sensitive information via logged messages.

    example
    logger.transform(
      formatString(),
      maskSecrets([/(?<=[A-Z0-9_]\=)\w+/g])
    ).subscribe(
      writeConsole()
    );
    
    logger.info("logged in USER=toxi, using TOKEN=123456");
    // [INFO] logger-0: logged in USER=****, using TOKEN=****

    Parameters

    • patterns: RegExp[]

      -

    • Default value mask: string = "****"

      -

    Returns Transducer<string, string>

Generated using TypeDoc