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

dashrun

v0.2.5

Published

Run a node.js script and watch its memory usage on a terminal dashboard

Downloads

6

Readme

dashrun

NPM ci

Run a node.js script and watch process execution on a terminal dashboard.

npx dashrun your_script.js [arg...]

dashrun comes with a built-in memory dashboard and allows you to create custom ones.

image

Create a custom dashboard

Probe

You need first to create a probe to send message from your script (forked process) to the dashboard.

A probe can be a simple line of code in your script:

let message = { eventName: "myEvent", data: Math.random() };
process.send(message);

or a file:

//myProbe.js (dashrun will automatically inject this file into your script)
setInterval(() => {
  //Sending every second to the dashboard a message with a random value
  process.send({ eventName: "myEvent", data: Math.random() });
}, 1000);

Note that message must be sent with process.send core function.

Dashboard

A dashboard is a function whose role is to run the script and render informations when script fires events.

module.exports = (script) => {
  // Prepare UI components
  // Run the script
  // Update UI components on new script events
};

You are free to use any library to create a dashboard.

blessed-contrib is a good choice and dashrun comes with a thin layer over it to ease dashboard construction.

const path = require("path");
const contrib = require("blessed-contrib");
const { DashboardLayout } = require("dashrun");

module.exports = (script) => {

  //Create a layout and define area where bless-contrib components will be rendered
  let layout = new DashboardLayout();
  let topLeft = layout.area(0, 0, 6, 6);
  let topRight = layout.area(0, 6, 6, 6);

  //Create a component, add it to layout and then render
  let component = contrib.lcd({
    label: "Current value",
    color: "red",
    ...topLeft, //Set position of the component
  });
  layout.add(component);
  layout.render();

  //Run the script with your custom probe
  let probe = path.join(__dirname, "myProbe.js");
  script.run([probe]);

  //Listen to events sent by the probe and update component
  script.on("myEvent", (data) => {
    component.setDisplay(data);
    layout.render();
  });
};