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

consoo

v0.0.3

Published

A set of helper functions for quick and dirty frontend debugging

Downloads

200

Readme

consoo

A set of helper functions for quick and dirty frontend debugging.

Usage

First, install the package:

npm install -D consoo
# or
pnpm install -D consoo

Then, import and initialize:

import { initConsoo } from "consoo";

initConsoo({
  // ... init options
});

consoo.log("foo");
consoo("bar").debug("baz");
// ...

If you use typescirpt:

import { initConsoo, type Consoo } from "consoo";

declare global {
  const so: Consoo;
}

initConsoo({
  alias: "so",
  // ... init options
});

so.log("foo");
so("bar").debug("baz");
// ...

Init options and the defaults:

initConsoo({
  noop: false, // if true, all methods will be no-op
  alias: "consoo", // string | string[], global access names, e.g. "so"
  defaultLogLevel: "info", // "info" | "warn" | "error" | "debug"
  prefix: undefined, // string | undefined, prefix for all messages
  markStyle: {
    padding: "2px",
  }, // mark css style
  markColors: [
    { bg: "#5151db", fg: "#fff" },
    { bg: "#5cc290", fg: "#fff" },
    { bg: "#860418", fg: "#fff" },
    { bg: "#dddddd", fg: "#000" },
    { bg: "#000000", fg: "#fff" },
    { bg: "#555555", fg: "#fff" },
    { bg: "#ff664d", fg: "#fff" },
    { bg: "#d4b475", fg: "#fff" },
    { bg: "#8f5465", fg: "#fff" },
    { bg: "#3fffff", fg: "#000" },
    { bg: "#7f4ac3", fg: "#fff" },
    { bg: "#fc9cff", fg: "#fff" },
  ], // mark color list
});

Helpers

console wrapper & message mark

  • All console methods are also available in consoo object: log info warn error debug trace dir dirxml table group groupCollapsed groupEnd clear count countReset assert time timeLog timeEnd timeStamp profile profileEnd

  • consoo can be called with a string or number first, which will be printed with a colored background, acting as a mark/tag for the following message.

consoo.log("foo");
consoo("mark").log("foo");

pause after delay

  • Pause the script execution after a delay, can be useful when debugging hover-state ui or dom-changing issues.

  • You may call it directly in devtools console.

consoo.pause(3000); // default delay is 0 ms

message separator

  • Print a separator line in the console panel.
consoo.sep("=", 80); // (repeator?: string, len?: number) => void

inspect & trace & monitor

  • Inspect (print to console) a variable or expression, return the value as is, can be useful when you don't borther to add a separate console.log line or re-type all the expression.
consoo.inspect(foo);
consoo.inspect("mark", foo + bar * baz); // you can add a mark too
  • Print the call stack and arguments every time the specific function is called.
let foo = (a, b) => a + b;
foo = consoo.traceFn(foo);
foo(1, 2); // will print the call stack and arguments
  • Print the call stack every time the specific object property is accessed (get or set).
consoo.traceProp(obj, "prop");
  • Monitor the document.activeElement change.
consoo.monitorActiveElement(); // return a function to stop monitoring
consoo.stopMonitorActiveElement(); // or you can stop it directly

vconsole for mobile debugging

  • Load and initialize vConsole (A simulated devtool for mobile web page) on the fly, without installing it as a dependency.
consoo.v(); // (VConsoleInitOption?: { theme: "dark" | "light" }) => void