{"dist":{"shasum":"f19175fec9ba79c937fb2a3149650dd94716e3ff","tarball":"https://registry.npmjs.org/monocle/-/monocle-0.1.42.tgz","integrity":"sha512-g1IayDq9ruEsZ0q2tgkDeAOMuCDMzNhXTfCqy45Tx+wmxSk5T5Vlumhbbd++F9uaclWSVNGn690+dqJ2IbWzzQ==","signatures":[{"sig":"MEYCIQDe2RBY6viOpLNILZAgk9hLHToqsxEADxagJOrLjUu7NwIhAJmABWAuLMOAYSyd95lwLAxzmjpgcJmBbemMB9o/3+BQ","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}]},"main":"monocle.js","name":"monocle","_from":".","author":{"name":"Sam Saccone"},"readme":"[![Build Status](https://travis-ci.org/samccone/monocle.png?branch=master)](https://travis-ci.org/samccone/monocle)\n\n# Monocle -- a tool for watching things\n\n[![logo](https://raw.github.com/samccone/monocle/master/logo.png)](https://raw.github.com/samccone/monocle/master/logo.png)\n\nHave you ever wanted to watch a folder and all of its files/nested folders for changes. well now you can!\n\n## Installation\n\n```\nnpm install monocle\n```\n\n## Usage\n\n### Watch a directory:\n\n```js\nvar monocle = require('monocle')()\nmonocle.watchDirectory({\n  root: <root directory>,\n  fileFilter: <optional>,\n  directoryFilter: <optional>,\n  callback: fn(filename), //triggered on file change\n  complete: <fn(fs.stat+ object)> //file watching all set up\n});\n```\n\nThe callback will recive an object with the following\n\n```js\n  name: <filename>,\n  path: <filepath-relative>,\n  fullPath: <filepath-absolute>,\n  parentDir: <parentDir-relative>,\n  fullParentDir: <parentDir-absolute>,\n  stat: <see fs.stats>\n```\n\n[fs.stats](http://nodejs.org/api/fs.html#fs_class_fs_stats)\n\nWhen a new file is added to the directoy it triggers a file change and thus will be passed to your specified callback.\n\nThe two filters are passed through to `readdirp`.  More documentation can be found [here](https://github.com/thlorenz/readdirp#filters)\n\n### Watch a list of files:\n\n```js\nMonocle.watchFiles({\n  files: [], //path of file(s)\n  callback: <fn(fs.stat+ object)>, //triggered on file change\n  complete: <fn> //file watching all set up\n});\n```\n\n## Why not just use fs.watch ?\n\n  - file watching is really bad cross platforms in node\n  - you need to be smart when using fs.watch as compared to fs.watchFile\n  - Monocle takes care of this logic for you!\n  - windows systems use fs.watch\n  - osx and linux uses fs.watchFile\n\n\n## License\n\nBSD\n","license":"BSD","scripts":{"test":"mocha test -R spec -t 2000"},"_npmUser":{"name":"samccone","email":"samccone@gmail.com"},"keywords":["watch","filesystem","folders","fs"],"repository":"","_npmVersion":"1.2.11","description":"a tool for watching directories for file changes","directories":{"test":"test"},"maintainers":[{"name":"samccone","email":"samccone@gmail.com"}],"dependencies":{"readdirp":"~0.2.3"},"readmeFilename":"README.md","devDependencies":{"mocha":"1.8.1"},"_id":"monocle@0.1.42","version":"0.1.42"}