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 🙏

© 2025 – Pkg Stats / Ryan Hefner

@ms-cloudpack/file-watcher

v0.4.30

Published

A file watcher abstraction for use with Cloudpack.

Readme

@ms-cloudpack/file-watcher

An abstraction on the file watching capabilities used in Cloudpack.

Example usage

  1. Create a watcher:
const watcher = createWatcher();
  1. Subscribe to a particular package path using watch. (Returns an unwatch function.)
const unwatch = await watcher.watch({ path: 'path/to/package' }, () => console.log(`package changed`));
  1. To dispose, call the returned unwatch, or call watcher.dispose to unsubscribe from all watchers.
// Dispose an individual watcher.
await unwatch();

// Dispose all watchers.
await watcher.dispose();

createWatcher options

  • type ('default' | 'fork', optional): By default, this will create a watcher in the same thread. Use type: 'fork' to create the watcher in a forked process.
  • backend ('default' | 'parcel', optional): Choose the file watching backend.
    • 'default': Uses chokidar (default)
    • 'parcel': Uses @parcel/watcher for better performance
  • policies (optional): Enable performance optimizations
    • 'shared-root': Multiplexes N package watches into 1 root watch (for monorepos with 100+ packages)
    • 'debounce': Batches rapid file changes into single notifications

Shared Root Watcher for Large Monorepos

For optimal performance when watching many packages (100+), use SharedRootWatcher - an orchestrator that wraps any watcher:

import { SharedRootWatcher, createWatcher } from '@ms-cloudpack/file-watcher';

// Create underlying watcher (can be any backend)
const underlyingWatcher = createWatcher({ backend: 'default' });

// Wrap it with SharedRootWatcher orchestrator
const watcher = new SharedRootWatcher(underlyingWatcher, '/path/to/monorepo');

// Watch multiple packages efficiently (single OS watcher)
await watcher.watch({ path: '/path/to/monorepo/packages/pkg1' }, onPkg1Change);
await watcher.watch({ path: '/path/to/monorepo/packages/pkg2' }, onPkg2Change);
// ... 1000+ packages

This uses a single file system watcher at the root instead of creating one per package.

With Parcel backend for maximum performance:

const underlyingWatcher = createWatcher({ backend: 'parcel' });
const watcher = new SharedRootWatcher(underlyingWatcher, '/path/to/monorepo');

watcher.watch options

  • path (string): The absolute root path to be watched.
  • id (string, optional): ID for the watch job (defaults to path). If you call watch twice using the same id, subsequent calls will be ignored.
  • watchPaths (string[], optional): Relative paths/globs from the root path. Currently, only negative globs (starting with !) are supported and will be used to ignore files. Positive globs are ignored - the watcher will watch all files in the root path by default. Defaults are under "@ms-cloudpack/path-utilities" in sourceFilesGlobs.