Socket
Socket
Sign inDemoInstall

@parcel/watcher

Package Overview
Dependencies
108
Maintainers
1
Versions
34
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @parcel/watcher

Blazing fast, zero configuration web application bundler


Version published
Weekly downloads
3.8M
increased by5.78%
Maintainers
1
Install size
3.03 MB
Created
Weekly downloads
 

Package description

What is @parcel/watcher?

The @parcel/watcher package is a file system watcher that provides an efficient way to subscribe to changes in the file system. It is designed to be fast and works across multiple platforms. It can be used to watch for changes in files and directories and perform actions in response to those changes.

What are @parcel/watcher's main functionalities?

Subscribing to file changes

This feature allows you to subscribe to changes in a specific directory. The callback function is called with an array of events whenever a change occurs. Each event contains the type of change (e.g., 'create', 'update', 'delete') and the path to the affected file or directory.

const {subscribe} = require('@parcel/watcher');

async function run() {
  await subscribe('/path/to/directory', (err, events) => {
    if (err) {
      // Handle the error
      return;
    }

    // Handle file system change events
    events.forEach(event => {
      console.log(`Type: ${event.type}, Path: ${event.path}`);
    });
  });
}

run();

Unsubscribing from file changes

This feature allows you to unsubscribe from a previously established subscription. This is useful when you no longer need to watch for changes or when your application is shutting down.

const {subscribe, unsubscribe} = require('@parcel/watcher');

let subscription;

async function run() {
  subscription = await subscribe('/path/to/directory', (err, events) => {
    // Handle file system change events
  });
}

async function stop() {
  await unsubscribe(subscription);
}

run();
// Later on, when you want to stop watching
stop();

Other packages similar to @parcel/watcher

FAQs

Last updated on 06 Oct 2019

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc