API Docs for: 0.2.2
Show:

R.Debug Class

Defined in: src\R.Debug.js:7

Debugging utilities embedded with R.
Provides conditionals for dev/prod mode and associated assertions to avoid lengthy try/catch blocks in prod mode.

Methods

_mode

() String private

Defined in src\R.Debug.js:15

Returns:

String:

string The basic string

breakpoint

() public

Defined in src\R.Debug.js:134

Trigger a debugger breakpoint without raising jshint errors.

check

() Boolean public

Defined in src\R.Debug.js:158

Runs assert from node core with the same arguments.
Throws if the assert fails and the current mode is dev.
console.error if the assert fails and the current mode is prod.
No side effect if the assert doesn't fail.

Returns:

Boolean:

Truthy only if the assert doesn't fail. False if the assert fails and not in dev mode.

dev

(
  • fn
)
public

Defined in src\R.Debug.js:92

Runs a function iff the current mode is dev.

Parameters:

  • fn Function

    The function to invoke iff the current mode is dev.

Returns:

:
  • The return value of fn iff the current mode is dev, undefined otherwise.

extendError

(
  • originalErr
  • wrappingErr
)
Error public

Defined in src\R.Debug.js:183

Extends an Error to provide additional information while preserving the error stack.
Uses VError under the hood.

Parameters:

  • originalErr Error

    The original error.

  • wrappingErr Error | String

    The error to use as wrapper.

Returns:

Error:

The new, extended Error.

isDev

() Boolean public

Defined in src\R.Debug.js:74

Returns a boolean describing whether the current mode is dev.

Returns:

Boolean:

boolean Truthy iff the current mode is dev.

isProd

() Boolean public

Defined in src\R.Debug.js:83

Returns a boolean describing whether the current mode is prod.

Returns:

Boolean:

boolean Truthy iff the current mode is prod.

maybeDev

(
  • fn
)
Function public

Defined in src\R.Debug.js:112

Returns a function iff the current mode is dev, otherwise returns a noop function.
"dev-only" maybe monad.

Parameters:

  • fn Function

    The function to be returned if the current mode is dev.

Returns:

Function:

The original function iff the current mode is dev, no-op function otherwise.

maybeProd

(
  • fn
)
Function public

Defined in src\R.Debug.js:123

Returns a function iff the current mode is prod, otherwise returns a noop function.
"prod-only" maybe monad.

Parameters:

  • fn Function

    The function to be returned if the current mode is prod.

Returns:

Function:

The original function iff the current mode is prod, no-op function otherwise.

prod

(
  • fn
)
public

Defined in src\R.Debug.js:102

Runs a function iff the current mode is prod.

Parameters:

  • fn Function

    The function to invoke iff the current mode is prod.

Returns:

:
  • The return value of fn iff the current mode is prod, undefined otherwise.

rethrow

(
  • [wrappingErr]
)
public

Defined in src\R.Debug.js:196

Returns a function that will rethrow when passed an error.

Parameters:

  • [wrappingErr] Error | String optional

    Optionnal error to use as wrapper.

setMode

(
  • mode
)
public

Defined in src\R.Debug.js:31

Manually override mode to either 'production' or 'development'.
Use this if you don't want to use envify.

Parameters:

  • mode String