Projekt

Obecné

Profil

Stáhnout (2.92 KB) Statistiky
| Větev: | Revize:
1
# fsevents [![NPM](https://nodei.co/npm/fsevents.png)](https://nodei.co/npm/fsevents/)
2

    
3
Native access to OS X FSEvents in [Node.js](http://nodejs.org/)
4

    
5
The FSEvents API in OS X allows applications to register for notifications of
6
changes to a given directory tree. It is a very fast and lightweight alternative
7
to kqueue.
8

    
9
This is a low-level library. For a cross-compatible file watching module that
10
uses fsevents, check out [Chokidar](https://www.npmjs.com/package/chokidar).
11

    
12
* [Module Site & GitHub](https://github.com/strongloop/fsevents)
13
* [NPM Page](https://npmjs.org/package/fsevents)
14

    
15
## Installation
16

    
17
	$ npm install fsevents
18

    
19
## Usage
20

    
21
```js
22
var fsevents = require('fsevents');
23
var watcher = fsevents(__dirname);
24
watcher.on('fsevent', function(path, flags, id) { }); // RAW Event as emitted by OS-X
25
watcher.on('change', function(path, info) { }); // Common Event for all changes
26
watcher.start() // To start observation
27
watcher.stop()  // To end observation
28
```
29

    
30
### Events
31

    
32
 * *fsevent* - RAW Event as emitted by OS-X
33
 * *change* - Common Event for all changes
34
 * *created* - A File-System-Item has been created
35
 * *deleted* - A File-System-Item has been deleted
36
 * *modified* - A File-System-Item has been modified
37
 * *moved-out* - A File-System-Item has been moved away from this location
38
 * *moved-in* - A File-System-Item has been moved into this location
39

    
40
All events except *fsevent* take an *info* object as the second parameter of the callback. The structure of this object is:
41

    
42
```js
43
{
44
  "event": "<event-type>",
45
  "id": <eventi-id>,
46
  "path": "<path-that-this-is-about>",
47
  "type": "<file|directory|symlink>",
48
  "changes": {
49
    "inode": true, // Has the iNode Meta-Information changed
50
    "finder": false, // Has the Finder Meta-Data changed
51
    "access": false, // Have the access permissions changed
52
    "xattrs": false // Have the xAttributes changed
53
  },
54
  "flags": <raw-flags>
55
}
56
```
57

    
58
## MIT License
59

    
60
Copyright (C) 2010-2014 Philipp Dunkel
61

    
62
Permission is hereby granted, free of charge, to any person obtaining a copy
63
of this software and associated documentation files (the "Software"), to deal
64
in the Software without restriction, including without limitation the rights
65
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
66
copies of the Software, and to permit persons to whom the Software is
67
furnished to do so, subject to the following conditions:
68

    
69
The above copyright notice and this permission notice shall be included in
70
all copies or substantial portions of the Software.
71

    
72
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
73
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
74
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
75
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
76
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
77
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
78
THE SOFTWARE.
(4-4/8)