@rslike/dbg
TypeScript icon, indicating that this package has built-in type declarations

3.0.0 • Public • Published

@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

/@rslike/dbg/

    Package Sidebar

    Install

    npm i @rslike/dbg

    Weekly Downloads

    1

    Version

    3.0.0

    License

    MIT

    Unpacked Size

    29.6 kB

    Total Files

    10

    Last publish

    Collaborators

    • vitalicset