Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

fb-watchman

Package Overview
Dependencies
Maintainers
5
Versions
17
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fb-watchman

Bindings for the Watchman file watching service

  • 2.0.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
23M
decreased by-3.65%
Maintainers
5
Weekly downloads
 
Created

What is fb-watchman?

The fb-watchman npm package is a file watching service developed by Facebook that provides a subscription-based API for monitoring file changes. It is designed to be efficient and scales well for large file systems, making it suitable for applications that need to keep track of changes in the file system in real-time.

What are fb-watchman's main functionalities?

Subscribe to file changes

This code sample demonstrates how to use fb-watchman to subscribe to changes in JavaScript files within a specified project directory. It sets up a watch, creates a subscription, and logs any changes to the console.

const watchman = require('fb-watchman');
const client = new watchman.Client();
client.capabilityCheck({optional:[], required:['relative_root']}, function(error, resp) {
  if (error) {
    console.error(error);
    client.end();
    return;
  }
  // Initiate the watch
  client.command(['watch-project', '/path/to/project'], function(error, resp) {
    if (error) {
      console.error('Error initiating watch:', error);
      return;
    }
    // Create a subscription
    client.command(['subscribe', resp.watch, 'mysubscription', {
      expression: ['allof', ['match', '*.js']],
      fields: ['name', 'size', 'mtime_ms', 'exists', 'type']
    }], function(error, resp) {
      if (error) {
        console.error('Error creating subscription:', error);
        return;
      }
      console.log('Subscription established', resp.subscribe);
    });
  });
});
client.on('subscription', function(resp) {
  if (resp.subscription === 'mysubscription') {
    console.log('File changed:', resp);
  }
});

Other packages similar to fb-watchman

Keywords

FAQs

Package last updated on 21 Sep 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc