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 🙏

© 2026 – Pkg Stats / Ryan Hefner

symmetra

v0.0.14

Published

A small file watcher utility

Readme

symmetra

A small file watcher utility

Installation

# using npm
npm install symmetra

# using yarn
yarn add symmetra

What this library is for

I created this library to help with another library that I was creating (a small javascript testing framework called Chaaya). Here is some example usage:

const { fileExtensions, excludeFiles, interval } = require("./utils");
const Watcher = require("symmetra");

const baseUrl = __dirname;
const doWatch = true;

function testWatcher() {
  const watcher = new Watcher(
    baseUrl,
    fileExtensions,
    excludeFiles,
    interval,
    acceptFileList,
    detectChange,
    doWatch
  );
  watcher.start();
}

First things first. There are a few things we need to pass into this class:

  • Files to exclude
  • File extensions to target
  • Interval
  • Callback when file list is created
  • Callback when a file change is detected
  • doWatch

Files to exclude

Normally you will want to include files like these

  • .git
  • bin
  • node_modules
  • .gitignore
  • package.json
  • package-lock.json

I normally put these in a config file like this:

module.exports = {
  extensions: ["test.js", "spec.js"],
  excludeFiles: [
    ".git",
    "bin",
    "node_modules",
    ".gitignore",
    "package.json",
    "package-lock.json",
    ".github",
  ],
  interval: 4000,
};

Then I will import this into my project to get the settings for the watcher.

File extensions to target

This would include things like

  • test.js
  • spec.js

Once the javascript files are found, they are narrowed down by using this list of file extensions.

Interval

This is used by fs.watchFile. This is the polling interval in which file changes are detected.

Callback when file list is created

This funtion is used just to the get list of files that have been gathered by the current configuration. Ex: Only test files that exist in this project. By default, you do not have to have the watcher watch files. It can simply search your project directory and send you back a list of files that match your needs.

  • ToDo: Add additional configuration to search base files that are not just .js file before filtering by the fileExtensions config.

Callback when a file change is detected

This function is triggered when one of the watched files detects a change. Here is the signature for this function:

function detectChange(file, curr, prev) {
  console.log("change detected");
  console.log(file);
  console.log(curr);
  console.log(prev);
  runSingleTestFile(file);
}

This utility is proving to be a sweet little utility to help me build my javascript testing library. Download and enjoy and if you find something that could be improved upon please fork and create a pull request.