5.0.1 • Published 2 years ago

simple-watcher v5.0.1

Weekly downloads
9,129
License
MIT
Repository
github
Last release
2 years ago

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}`)
}
5.0.1

2 years ago

5.0.0

3 years ago

4.0.2

3 years ago

4.0.1

4 years ago

4.0.0

5 years ago

3.0.0

7 years ago

2.0.1

7 years ago

2.0.0

7 years ago

1.0.5

8 years ago

1.0.4

8 years ago

1.0.3

8 years ago

1.0.2

8 years ago

1.0.1

8 years ago

1.0.0

8 years ago

0.1.2

8 years ago

0.1.1

8 years ago

0.1.0

8 years ago

0.0.1-alpha

8 years ago