@rslike/dbg
v3.0.0
Published
Never use console.log to debug again!
Downloads
8
Maintainers
Readme
@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): 456
Similarry,
const d = {'key': {1: 'one'}}
dbg(() => d['key'][1])
class Klass{
static attr = 'yep'
}
dbg(() => Klass.attr)
Installation
NPM:
npm i @rslike/dbg
YARN/PNPM:
yarn add @rslike/dbg
pnpm add @rslike/dbg
WIKI
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.log
delimiter
- delimiter between variable name and it's value.
Returns an object with next fields:
name
- variable nametype
- returns fromtypeof
operator.value
- variable value.prefix
- called prefix from optionsdelimiter
- called delimiter from options