-
Notifications
You must be signed in to change notification settings - Fork 0
03 dbg
Vitali Haradkou edited this page Apr 10, 2024
·
1 revision
pnpm:
pnpm add @rslike/dbg -D
npm:
npm i @rslike/dbg -D
yarn:
yarn add @rslike/dbg -D
import { dbg } from '@rslike/dbg';
// or import default
import dbg from '@rslike/dbg';
const a = 123;
dbg(() => a); // a: 123
It also supports BigInt
, Symbol
and undefined
and null
.
Example:
// BigInt
const a = 123n
dbg(() => a) // a: 123n
// Symbol
const b = Symbol('foo')
dbg(() => b) // b: Symbol(foo)
const information = dbg(() => b, {skipConsoleLog: true}) // nothing to print
console.log('variable name: ', information.name) // variable name: b
console.log('type: ', information.type) // type: symbol
-
fn
- arrow function. -
opts
- object with next arguments-
prefix
- 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 name -
type
- returns fromtypeof
operator. -
value
- variable value. -
prefix
- called prefix from options -
delimiter
- called delimiter from options