A tiny, zero overhead debugging utility.
npm install nanodebug
By default, nanodebug is completely noop:
const debug = require('nanodebug')()
// Does nothing!
debug('You encountered a %s!', '🐛')
// Also does nothing!
debug(() => { debug('It accepts functions as well') })
// This... does nothing!
await debug(async () => { debug('They can even be async!') })
Go ahead and put some debugs in your code and enable nanodebug when :bug: hits the fan:
const debug = require('nanodebug')({ enabled: true })
By default, debug will log to stderr using console.error, which is also why we were able to specify a formatting string in the examples above. To change this, pass a log function in the options:
const debug = require('nanodebug')({ log: console.log.bind(console) })
Now, debug will instead log to stdout using console.log.
ISC