3.0.0 • Published 5 months ago

@rslike/dbg v3.0.0

Weekly downloads
-
License
MIT
Repository
-
Last release
5 months ago

@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 arguments
    • prefix - prefix before message. Default is dbg |
    • outputFunction - function to print output. Default is console.log
    • delimiter - delimiter between variable name and it's value.

Returns an object with next fields:

  • name - variable name
  • type - returns from typeof operator.
  • value - variable value.
  • prefix - called prefix from options
  • delimiter - called delimiter from options
3.0.0

5 months ago

2.1.2

1 year ago

2.1.1

1 year ago

2.1.0

1 year ago