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

fam.js

v1.1.2

Published

fam/gamin bindings for node

Downloads

5

Readme

fam.js

Fam wrapper for node

USAGE

Grab a fam object:

var mon = new fam.FAM()

Add some files or directories:

mon.addPaths("/tmp");
mon.addPaths("/tmp/foo", "/tmp/bar", "/var/tmp");

And watch!

mon.watch(function(ev) {
    console.log(ev.filename);
    console.log(ev.event_type);
});

FAQ

Doesn't node already have something like this that doesn't rely on fam?

Yes. It's fs.watch(). But it's bad! Here's why!

  1. It's listed as unstable. fam has been around forever, so it's way more stable than any bullshit the node devs put together
  2. It uses inotify on linux. This is great if you HAVE inotify. It sure does suck if you don't. fam works in either instance
  3. It only works on some BSDs, Linux, Solaris and Windows. If you have something else, you're fucked. Good thing fam is pretty universal

Isn't fs.watch() faster because it uses the OS's native file watching implementation?

Well...yes. However, if you want that support, install gamin instead of fam. gamin is a drop in replacement for fam, and will make use of the OS's native file wawtching syscalls if they're there.

It also handles NFS way more intelligently than fs.watch() ever could.

Well fuck, you sure did sell me on this fam business. What do I need to use your module?

  • node-waf and a c++ compiler
  • mocha if you want to run the tests
  • fam or gamin

You sure do mention gamin a lot...can you tell me more?

gamin is a drop in replacement for fam made by some guy at GNOME. It uses the OS's file watching syscalls (inotify, dnotify, kqueue, etc.) if they're available, and if not, falls back to polling.

fam just straight up polls. That's dumb.

fam also likes to spam you with a ton of exists and endexists events when you watch a directory. gamin has an option to turn that off (which I've enabled when you build my module against gamin).

By default, gamin uses polling on NFS mounts. If it used inotify/dnotify/kqueue/whatever, you wouldn't get any notifications if anything changed on your NFS mounts. That sucks.

gamin is configurable. In the rare case that you want to define how gamin checks a directory...you can do that. Edit /etc/gamin/gaminrc or ~/.gaminrc to set this up. Here's a guide!

Go modern and get gamin.