Options
All
  • Public
  • Public/Protected
  • All
Menu

Module utils

Index

Functions

canonicalize

  • canonicalize(value: any, stack: any[], typeHint: string): any
  • Return a new Thing that has the keys in sorted order. Recursive.

    If the Thing...

    • has already been seen, return string '[Circular]'
    • is undefined, return string '[undefined]'
    • is null, return value null
    • is some other primitive, return the value
    • is not a primitive or an Array, Object, or Function, return the value of the Thing's toString() method
    • is a non-empty Array, Object, or Function, return the result of calling this function again.
    • is an empty Array, Object, or Function, returns '[]', '{}', or '[Function]' respectively.
    see

    https://mochajs.org/api/module-utils.html#.canonicalize

    Parameters

    • value: any
    • stack: any[]
    • typeHint: string

    Returns any

clean

  • clean(str: string): string

getError

highlight

  • highlight(js: string): string
  • Highlight the given string of js.

    Parameters

    • js: string

    Returns string

lookupFiles

  • lookupFiles(filepath: string, extensions?: string[], recursive?: undefined | false | true): string[]

slug

  • slug(str: string): string

stackTraceFilter

  • stackTraceFilter(): function
  • When invoking this function you get a filter function that get the Error.stack as an input, and return a prettify output. (i.e: strip Mocha and internal node functions from stack trace).

    see

    https://mochajs.org/api/module-utils.html#.stackTraceFilter

    Returns function

      • (stack: string): string
      • Parameters

        • stack: string

        Returns string

stringify

  • stringify(value: any): string
  • Stringify value. Different behavior depending on type of value:

    • If value is undefined or null, return '[undefined]' or '[null]', respectively.
    • If value is not an object, function or array, return result of value.toString() wrapped in double-quotes.
    • If value is an empty object, function, or array, returns '{}', '[Function]', or '[]' respectively.
    • If value has properties, call canonicalize} on it, then return result of JSON.stringify()
    see

    https://mochajs.org/api/module-utils.html#.stringify

    Parameters

    • value: any

    Returns string

type

  • type(value: any): string
  • Takes some variable and asks Object.prototype.toString() what it thinks it is.

    Parameters

    • value: any

    Returns string

undefinedError

  • undefinedError(): Error

Generated using TypeDoc