3.1.0 • Published 10 months ago
@rslike/dbg v3.1.0
@rslike/dbg
Never use console.log to debug again
Inspect Variables
Have you ever printed variables or expressions to debug your program? If you've ever typed something like
console.log(foo('123'))or the more thorough
console.log("foo('123')", foo('123'))then @rslike/dbg will put a smile on your face. With arguments, dbg inspects itself and prints both its own arguments and the values of those arguments.
import {dbg} from '@rslike/dbg'
function foo(i){
return i + 333;
}
dbg(() => foo(123))Prints:
foo(123): 456Similarry,
const d = {'key': {1: 'one'}}
dbg(() => d['key'][1])
class Klass{
static attr = 'yep'
}
dbg(() => Klass.attr)Installation
NPM:
npm i @rslike/dbgYARN/PNPM:
yarn add @rslike/dbg
pnpm add @rslike/dbgWIKI
Available by link: https://github.com/vitalics/rslike/wiki/Debug
Related packages
API
dbg(fn, opts)
fn- arrow function.opts- object with next argumentsprefix- prefix before message. Default isdbg |outputFunction- function to print output. Default isconsole.logdelimiter- delimiter between variable name and it's value.
Returns an object with next fields:
name- variable nametype- returns fromtypeofoperator.value- variable value.prefix- called prefix from optionsdelimiter- called delimiter from options