{
  "name": "watch",
  "description": "Utilities for watching file trees.",
  "tags": [
    "util",
    "utility",
    "fs",
    "files"
  ],
  "version": "0.8.0",
  "homepage": "https://github.com/mikeal/watch",
  "bugs": {
    "url": "https://github.com/mikeal/watch/issues"
  },
  "repository": {
    "type": "git",
    "url": "git://github.com/mikeal/watch.git"
  },
  "author": {
    "name": "Mikeal Rogers",
    "email": "mikeal.rogers@gmail.com"
  },
  "directories": {
    "lib": "lib"
  },
  "engines": [
    "node >=0.1.95"
  ],
  "main": "./main",
  "readme": "# watch -- Utilities for watching file trees in node.js\n\n## Install\n\n<pre>\n  npm install watch\n</pre>\n\n## Purpose\n\nThe intention of this module is provide tools that make managing the watching of file & directory trees easier.\n\n#### watch.watchTree(root, [options,] callback)\n\nThe first argument is the directory root you want to watch.\n\nThe options object is passed to fs.watchFile but can also be used to provide two additional watchTree specific options:\n\n* `'ignoreDotFiles'` - When true this option means that when the file tree is walked it will ignore files that being with \".\"\n* `'filter'` - You can use this option to provide a function that returns true or false for each file and directory that is walked to decide whether or not that file/directory is included in the watcher.\n\nThe callback takes 3 arguments. The first is the file that was modified. The second is the current stat object for that file and the third is the previous stat object.\n\nWhen a file is new the previous stat object is null.\n\nWhen watchTree is finished walking the tree and adding all the listeners it passes the file hash (key if the file/directory names and the values are the current stat objects) as the first argument and null as both the previous and current stat object arguments.\n\n<pre>\n  watch.watchTree('/home/mikeal', function (f, curr, prev) {\n    if (typeof f == \"object\" && prev === null && curr === null) {\n      // Finished walking the tree\n    } else if (prev === null) {\n      // f is a new file\n    } else if (curr.nlink === 0) {\n      // f was removed\n    } else {\n      // f was changed\n    }\n  })\n</pre>\n\n### watch.createMonitor(root, [options,] callback)\n\nThis function creates an EventEmitter that gives notifications for different changes that happen to the file and directory tree under the given root argument.\n\nThe options object is passed to watch.watchTree.\n\nThe callback receives the monitor object.\n\nThe monitor object contains a property, `files`, which is a hash of files and directories as keys with the current stat object as the value.\n\nThe monitor has the following events.\n\n* `'created'` - New file has been created. Two arguments, the filename and the stat object.\n* `'removed'` - A file has been moved or deleted. Two arguments, the filename and the stat object for the fd.\n* `'changed'` - A file has been changed. Three arguments, the filename, the current stat object, and the previous stat object.\n\n<pre>\n  var watch = require('watch')\n  watch.createMonitor('/home/mikeal', function (monitor) {\n    monitor.files['/home/mikeal/.zshrc'] // Stat object for my zshrc.\n    monitor.on(\"created\", function (f, stat) {\n      // Handle new files\n    })\n    monitor.on(\"changed\", function (f, curr, prev) {\n      // Handle file changes\n    })\n    monitor.on(\"removed\", function (f, stat) {\n      // Handle removed files\n    })\n  })\n</pre>\n",
  "readmeFilename": "readme.mkd",
  "_id": "watch@0.8.0",
  "dist": {
    "shasum": "d0654940f71a0ac44f425fdb3db0b0d197018d44"
  },
  "_from": "watch@~0.8.0",
  "_resolved": "https://registry.npmjs.org/watch/-/watch-0.8.0.tgz"
}
