- What is Q
- Sample output of using
q()
- Why is this better than
console.log
? - Changelog
- Install
- Usage
- Shell Integration
- Editor integrations
- FAQ
q
is a better way to do print statement debugging.Use
q
instead ofconsole.log
and your variables will be nicely printed in$TMPDIR/q
.
- ⚡ Faster to type
- 🍱 Pretty-printed vars and expressions
- 🔍 Easier to see inside objects
- 🙈 Does not go to noisy-ass stdout. It goes to
$TMPDIR/q
. - 🎨 Pretty colors!
Bonus points:
- Provide a type definition for completion in IDE
- Honor NO_COLOR environment variable to disable coloring
See CHANGELOG.md
npm install qqd
Tips: qqd
is for "Q is Quick Debugging".
const { q } = require("qqd");
q(a, b, c);
// Or shorter
require("qqd").q(a, b, c);
Then tail the q
file:
tail -f $TMPDIR/q
# Or if $TMPDIR is not defined:
tail -f /tmp/q
For best results, dedicate a terminal to tailing $TMPDIR/q
while you work, or see below the Shell integration.
To quickly open the Q file and clearing it, add this two functions to your shell.
Note that there is also a ZSH Plugin, see the instructions below.
These two functions allows you to quickly tail Q, or to empty the Q file and tail it:
$ qq
Tailing Q log...
06:14:11 foobar
$ rmqq # File is emptied before
Tailing Q log...
The ZSH Plugin for Q adds the two functions, qq
and rmqq
, as seen above to your shell.
Usage with Zgen (or any ZSH plugin manager):
zgen load tomsquest/q.plugin.zsh
Then you can:
$ qq
Tailing Q log...
06:14:11 foobar
$ rmqq # File is emptied before
Tailing Q log...
- In
Settings
- Open
Editor
>Live Templates
- In
JavaScript
, add a new template - Click on
Define
next toNo applicable contexts yet
and pickJavaScript and TypeScript
- Set:
- Abbreviation:
q
- Description:
Pretty-print with Q
- Template Text:
q($VAR$);
- Abbreviation:
- Open
Edit variables
and pickcompleteSmart()
in theExpression
column - Press
OK
- In
Settings
- Open
Editor
>Live Templates
- Click on the
+
icon and select >Template Group
and fill "TypeScript" - Go to the newly created group
TypeScript
, add a new template - Click on
Define
next toNo applicable contexts yet
and pickTypeScript
- Set:
- Abbreviation:
q
- Description:
Pretty-print with Q
- Template Text:
q($VAR$);
- Abbreviation:
- Open
Edit variables
and pickcompleteSmart()
in theExpression
column - Press
OK
Here, by pressing q
, I can select the first, or the second option:
Python programmers will recognize this as a Javascript port of the q
module by zestyping.
Go programmers will recognize this as a port of the q
module by y0ssar1an.
Ping does a great job of explaining q
in his awesome lightning talk from PyCon 2013. Watch it! It's funny :)
Because q
is quick to type ⚡⚡⚡.
On NPM, the q
, dd
("dirty debug") and even qdd
("quick dirty debug") were already published.
qqd
seems to be a good choice, short and meaning Q is Quick Debugging.
Yes. Q uses fs.writeFileSync()
so the writes are synchronous/blocking.
Q does not do anything if NODE_ENV is production
.
This is for safety: you do not want Q to write stuff when running in production.
Still, it is advised to prevent shipping any calls to Q before shipping code (like you could to for console.log
).
With ESLint, add the "Disallow specific imports (no-restricted-imports)" rules to an existing .eslintrc.js
:
"no-restricted-imports": ["error", "qqd"]
Alternative for Node.js, the ESLint Node plugin provides two rules:
Yes, it is largely inspired by the very good README of the q
module by y0ssar1an.