Options
All
  • Public
  • Public/Protected
  • All
Menu

Module utils

Index

Variables

Const NEWLINE_EXP

NEWLINE_EXP: RegExp = ...

Functions

chomp

  • chomp(line: any): any
  • Detects line returns if match slices, run before transform to retain consistent line returns.

    Parameters

    • line: any

      the line to be cleaned up.

    Returns any

cloneClass

  • cloneClass<T>(instance: T): any
  • Simple method to clone a class.

    Type parameters

    • T

    Parameters

    • instance: T

      the class instance you wish to clone.

    Returns any

colorize

  • colorize(str: string, ...styles: Color[]): any

createError

  • createError(err: string | (Error & Record<string, any>)): Error & Record<string, any>
  • Just creates a styled error message.

    Parameters

    • err: string | (Error & Record<string, any>)

      the error message or Error instance.

    Returns Error & Record<string, any>

ensureDefaults

  • ensureDefaults<T>(options: T, defaults: Partial<T>): T
  • Ensures an options object contains correct default values.

    Type parameters

    • T

    Parameters

    • options: T

      the options object to ensure defaults for.

    • defaults: Partial<T>

      the default values.

    Returns T

escapeRegex

  • escapeRegex(str: string): string
  • Escapes a regexp string.

    Parameters

    • str: string

      the string to escape.

    Returns string

isBlankLine

  • isBlankLine(line: string): boolean
  • Checks if line is a blank line after stripping any ansi styles or line returns.

    Parameters

    • line: string

      the line to be inspected.

    Returns boolean

pad

  • pad(str: string, dir: "left" | "right", spaces?: number): string
  • Pads a string left or right.

    Parameters

    • str: string

      the string to be padded.

    • dir: "left" | "right"

      the direction left or right.

    • spaces: number = 0

      the amount of padding to apply.

    Returns string

simpleTimestamp

  • simpleTimestamp(date?: Date, timeOnly?: boolean): string
  • Timestamp only supports long format e.g. 'YYYY.MM.DD HH:mm:ss' If you need more advanced formatting pass in "onTimestamp" handler in Spawnmon options.

    Parameters

    • date: Date = ...

      the date to create timestamp for.

    • timeOnly: boolean = true

    Returns string

truncate

  • truncate(str: string, max?: number, char?: string): string
  • Truncates a string.

    Parameters

    • str: string

      the string to be inspected or truncated.

    • max: number = 0

      the maximum length permissible.

    • char: string = '...'

      the trailing char when exceeds length.

    Returns string

Generated using TypeDoc