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

simple-watcher

Package Overview
Dependencies
Maintainers
1
Versions
18
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

simple-watcher

"A simple file s watcher."

  • 5.0.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
56K
increased by13.56%
Maintainers
1
Weekly downloads
 
Created
Source

Simple Watcher

A simple recursive directory watcher.

But why?

Most watchers do not seem to care about the recursive option of Node's fs.watch(), which significantly improves performance on the supported platforms, especially for large directories.

Features:

  • Simple, fast and lightweight.
  • No dependencies.
  • Leverages the recursive option on OS X and Windows for improved performance; uses a fallback for other platforms.
  • Takes care of WinAPI's ReadDirectoryChangesW double reporting.
  • Modern API without callbacks.

Usage

Command line

Usage:
  simple-watcher path1 [path2 path3 ...]

JavaScript

import watch from 'simple-watcher'

// Optional: abort the watcher after 10 seconds.
const ac = new AbortController()
setTimeout(() => ac.abort(), 10000)

// Watch over file or directory.
for await (const changedPath of watch('/path/to/foo'), { signal: ac.signal }) {
  console.log(`Changed: ${filePath}`)
}

// Watch over multiple paths.
for await (const changedPath of watch(['/path/to/bar', '/path/to/baz']), { signal: ac.signal }) {
  console.log(`Changed: ${filePath}`)
}

Keywords

FAQs

Package last updated on 11 Jul 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