Lightweight debugging. Wraps the amazing debug library to provide additional functionality.
string) - A prefix for all debugger namespaces when created with
boolean) - Print verbose messages logged from
debugger.verbose(), otherwise they are hidden.
Like logging, a "debugger" is a collection of functions that write to
The key difference is that debug messages are only displayed if the
DEBUG environment variable is
set and contains the debugger's namespace (logic provided by the
debug package). The namespace can be defined when
instantiating a debugger using
A namespace can either be a string or an array of strings.
Each debug function that logs (excluding invariants) requires a message string as the 1st argument, and an optional rest of arguments to interpolate into the message using util.format().
Invariant debugging logs either a success or a failure message, depending on the truthy evaluation
of a condition. This can be achieved with
debugger.invariant(condition: boolean, message: string, pass: string, fail: string), which
requires the condition to evaluate, a message to always display, and a success and failure message.
Debug messages are already hidden behind the
DEBUG environment variable, but Boost takes it a step
further to support verbose debugging. Messages logged with
debugger.verbose(message: string, ...args: any) will not be displayed unless the
BOOSTJS_DEBUG_VERBOSE environment variable is set -- even if
DEBUG is set.
By default, all logged messages are immediately written when
DEBUG contains the debugger
namespace. To silence output for a specific debugger, call the
debugger.disable() function, and to
Messages that are logged while silenced are lost and are not buffered.
The following Jest utilities are available in the
Returns a Jest spy that matches the return value shape of