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

memview

v0.3.2

Published

A web interface for Node.js that allows quick debugging and visualization of arrays.

Downloads

578

Readme

What is MemView ?

MemView is a web interface for Node.js that enables quick debugging and visualization of arrays.

  • 👍 Plug & Play
  • 🛠️ Fully customizable
  • ⚡ Optimized for fast rendering
  • 💻 CPU-only, no hardware acceleration required

Output

You can display items on a draggable and zoomable map:

  • 🔢 Log arrays (1D, 2D, and flattened 2D) ✅
  • 💬 Log messages in the console (log, warn, and error) ✅
  • 🖼️ Log images (RGB, RGBA) - Coming soon -
  • 📟 Log displays - Coming soon -
  • 🌳 Log tree structures - Potential future feature -
  • 🔊 Log audio (music, spatialized sounds) - Potential future feature -

Input

You can receive inputs:

  • 🖱️ Mouse events ✅
  • ⌨️ Keyboard events ✅
  • 🕹️ Gamepad events - Potential future feature -

Installation

npm i memview

Simple Example

Simple exemple with render mapping and output mapping.

import {
  MemView,
  MemViewMapper,
  MemViewMapperOutput,
  Vector2,
  Anchor,
  KeyCode,
  KeyEvent,
} from "memview";

(async () => {
  // Instanciate MemView
  const mem = new MemView();

  // Start it
  await mem.start({
    // Wait for interface to be opened
    waitForTab: true,
    // Automatically open interface at start
    openNewTab: true,
  });

  // Define how to render each cell of the array
  const customMapper: MemViewMapper = {
    cellBackgroundColor: (el: any) => {
      // If the value of cell is > 0.9, cell background will be red, else it will be green.
      return el > 0.9 ? "#a55" : "#5a5";
    },
    cellText: (el: any) => {
      // Show the value of the cell at the center of itself.
      return [
        {
          text: `${el.toFixed(2)}`,
          color: "#ccc",
          anchor: Anchor.Center,
          fontSize: 14,
        },
      ];
    },
    cellAtlasIndex: (el: any) => {
      // If you want to map a texture from an Atlas to your cell.
      // Not used here.
      return { x: 0, y: 0 };
    },
    details: (el: any) => {
      // Show the value of the hovered cell in the sidebar.
      return [`Value: ${el.toFixed(2)}`];
    },
  };

  // Define how to handle mouse events
  const customOutput: MemViewMapperOutput = {
    onHover: (position: Vector2) => {
      mem.log(`Mouse: ${position.x}/${position.y} -> Mouse Hovering`);
    },
    onMouseDown: (position: Vector2) => {
      mem.log(`Mouse: ${position.x}/${position.y} -> Mouse Down`);
    },
    onMouseUp: (position: Vector2) => {
      mem.log(`Mouse: ${position.x}/${position.y} -> Mouse Up`);
    },
  };

  // You can listen to keyboard event
  mem.bindKeyEvent((data: KeyEvent) => {
    // mem.log(`Keyboard: ${data.key} -> ${data.isPressed}`);
  });

  const myArray: number[][] = [];
  const size: Vector2 = { x: 16, y: 16 };

  // Init Array
  for (let iY = 0; iY < size.y; iY++) {
    myArray.push([]);
    for (let iX = 0; iX < size.x; iX++) {
      myArray[iY].push(Math.random());
    }
  }

  for (let i = 0; i < 10000; i++) {
    // Randomize the array for each iteration
    for (let iY = 0; iY < size.y; iY++) {
      for (let iX = 0; iX < size.x; iX++) {
        myArray[iY][iX] = Math.random();
      }
    }

    // Another way to get keyboard events.
    // KeyCode is bind on the physical position of the key.
    // That's mean that "KeyQ" is "Q" on QWERTY layout but "A" on AZERTY layout.
    mem.log("Q (QWERTY) / A (AZERTY) " + mem.getKey(KeyCode.KeyQ));

    await mem.log2d(
      // Array unique id
      "my_array_id",
      // Array reference
      myArray,
      // Options
      {
        // Wait for 1000ms before continuing.
        waitFor: 1000,
        // Wait for the array to be rendered before continuing.
        isSync: true,
        mapper: customMapper,
        output: customOutput,
      }
    );
  }
})();

Code Quality

Before 1.0.0

Features first, even to the detriment of code quality.

Since 1.0.0

Quality first.

Author

THP-Software