nsfw-watcher
TypeScript icon, indicating that this package has built-in type declarations

1.0.1 • Public • Published

NSFW Watcher

File system watcher based on NSFW that emits add/change/rename/unlink events.

Install

npm install --save nsfw-watcher

API

This library provides the following interface:

type Options = {
  debounceMS?: number,
  errorCallback?: Function
};
 
type Handlers = {
  add?: ( filePath: string ) => void,
  change?: ( filePath: string ) => void,
  rename?: ( prevFilePath: string, nextFilePath: string ) => void,
  unlink?: ( filePath: string ) => void
};
 
type Listener = {
  start (): Promise<void>,
  stop (): Promise<void>
};
 
function watcher ( path: string, options: Options, handlers: Handlers ): Promise<Listener>;

Usage

import watcher from 'nsfw-watcher';
 
const handlers = {
  add ( filePath ) { /* ... */ },
  change ( filePath ) { /* ... */ },
  rename ( prevFilePath, nextFilePath ) { /* ... */ },
  unlink ( filePath ) { /* ... */ }
};
 
watcher ( '/Users/fabio/Desktop', {}, handlers );

License

MIT © Fabio Spampinato

Package Sidebar

Install

npm i nsfw-watcher

Weekly Downloads

8

Version

1.0.1

License

MIT

Unpacked Size

11.4 kB

Total Files

11

Last publish

Collaborators

  • fabiospampinato