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

@liquid-labs/playground-monitor

v1.0.0-beta.4

Published

A file-watching utility to track changes to a developers "playground".

Downloads

9

Readme

playground-monitor

coverage: 97% Unit tests

A file-watching utility to track changes to a developers "playground". Specifically, creates a manifest of projects and watches for the introduction, removal, or changes in project directories and package.json files and updates the project manifest accordingly. Built on top of chokidar.

Installation

npm i @liquid-labs/playground-monitor

Usage

import * as path from 'node:path'

import { PlaygroundMonitor } from '@liquid-labs/playground-monitor' // ESM
// const { PlaygroundMonitor } = require('@liquid-labs/playground-monitor') // CJS

const playgroundPath = fsPath.join(process.env.HOME, 'playground')
const playground = new PlaygroundMonitor({ root: playgroundPath})
try {
  await playground.refreshProjects() // must be called to initalize the PlaygroundMonitor

  const { pkgJSON, projectPath } = playground.getProjectData('@liquid-labs/playground-monitor')
}
finally {
  playground.close() // must call to stop watchers and end process
}

Reference

  • PlaygroundMonitor.constructor({ depth = 2, root })
    Creates a new PlaygroundMonitor watching the playground at root which will look for projects (directories with package.json files) depth levels down.
    • depth: (opt, int, default: 2) how many levels of directories under root to watch
    • root: (req, string) the path to the playground root
  • PlaygroundMonitor.close():
    Stops the underlying watchers and frees resources. The node process will hang unlesss the Playground instance is closed.
  • PlaygroundMonitor.getProjectData(projectName)
    Retrieves the { pkgJSON, /*and*/ projectPath } for the project where pkgJSON is the contents of the projects package.json file as a JSON data object and projectPath is the absolute path to the project root (the directory where package.json lives).
    • projectName: (req, string) the name (from package.json) of the project/package.
  • getWatched()
    Returns an object representing all the paths on the file system being watched. The object's keys are all the directories (using absolute paths unless the cwd option was used), and the values are arrays of the names of the items contained in each directory.
  • PlaygroundMonitor.listProjects()
    Lists the known project names alphabetically as an array of strings.
  • async PlaygroundMonitor.refreshProjects()
    Asynchronously initializes the playground. This method must be called for the PlaygroundMonitor to function.