npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

qqd

v1.6.0

Published

Quick-and-dirty debugging output for tired programmers

Downloads

7

Readme

⚡ Quick-and-dirty debugging output for tired JS programmers

Q.JS

Version GitHub Workflow Status

What is Q

q is a better way to do print statement debugging.

Use q instead of console.log and your variables will be nicely printed in $TMPDIR/q.

Sample output of using q()

output sample

Why is this better than console.log?

  • :zap: Faster to type
  • :bento: Pretty-printed vars and expressions
  • :mag: Easier to see inside objects
  • :see_no_evil: Does not go to noisy-ass stdout. It goes to $TMPDIR/q.
  • :art: Pretty colors!

Bonus points:

Changelog

See CHANGELOG.md

Install

npm install qqd

Tips: qqd is for "Q is Quick Debugging".

Usage

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.

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...

ZSH Plugin for Q

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...

Editor integrations

Jetbrains Intellij and Webstorm

For JavaScript:

  1. In Settings
  2. Open Editor > Live Templates
  3. In JavaScript, add a new template
  4. Click on Define next to No applicable contexts yet and pick JavaScript and TypeScript
  5. Set:
    • Abbreviation: q
    • Description: Pretty-print with Q
    • Template Text: q($VAR$);
  6. Open Edit variables and pick completeSmart() in the Expression column
  7. Press OK

Add JavaScript live template in Jetbrains Intellij

For TypeScript:

  1. In Settings
  2. Open Editor > Live Templates
  3. Click on the + icon and select > Template Group and fill "TypeScript"
  4. Go to the newly created group TypeScript, add a new template
  5. Click on Define next to No applicable contexts yet and pick TypeScript
  6. Set:
    • Abbreviation: q
    • Description: Pretty-print with Q
    • Template Text: q($VAR$);
  7. Open Edit variables and pick completeSmart() in the Expression column
  8. Press OK

Add Typescript live template in Jetbrains Intellij

Sample usage

Here, by pressing q, I can select the first, or the second option:

Live template usage

FAQ

Haven't I seen this somewhere before?

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 :) ping's PyCon 2013 lightning talk

Why q?

Because q is quick to type ⚡⚡⚡.

Why the npm module is called qqd?

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.

Is q safe for concurrent use?

Yes. Q uses fs.writeFileSync() so the writes are synchronous/blocking.

What about production?

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).

How to prevent calls to Q in production?

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:

Haven't I seen this README somewhere before?

Yes, it is largely inspired by the very good README of the q module by y0ssar1an.