| 1 |
// @flow |
| 2 |
declare type FilePath = string; |
| 3 |
declare type GlobPattern = string; |
| 4 |
|
| 5 |
export type BackendType = |
| 6 |
| 'fs-events' |
| 7 |
| 'watchman' |
| 8 |
| 'inotify' |
| 9 |
| 'windows' |
| 10 |
| 'brute-force'; |
| 11 |
export type EventType = 'create' | 'update' | 'delete'; |
| 12 |
export interface Options { |
| 13 |
ignore?: Array<FilePath | GlobPattern | RegExp>; |
| 14 |
backend?: BackendType; |
| 15 |
} |
| 16 |
export type SubscribeCallback = (err: ?Error, events: Array<Event>) => mixed; |
| 17 |
export interface AsyncSubscription { |
| 18 |
unsubscribe(): Promise<void>; |
| 19 |
} |
| 20 |
export interface Event { |
| 21 |
path: FilePath; |
| 22 |
type: EventType; |
| 23 |
} |
| 24 |
declare module.exports: { |
| 25 |
getEventsSince( |
| 26 |
dir: FilePath, |
| 27 |
snapshot: FilePath, |
| 28 |
opts?: Options, |
| 29 |
): Promise<Array<Event>>, |
| 30 |
subscribe( |
| 31 |
dir: FilePath, |
| 32 |
fn: SubscribeCallback, |
| 33 |
opts?: Options, |
| 34 |
): Promise<AsyncSubscription>, |
| 35 |
unsubscribe( |
| 36 |
dir: FilePath, |
| 37 |
fn: SubscribeCallback, |
| 38 |
opts?: Options, |
| 39 |
): Promise<void>, |
| 40 |
writeSnapshot( |
| 41 |
dir: FilePath, |
| 42 |
snapshot: FilePath, |
| 43 |
opts?: Options, |
| 44 |
): Promise<FilePath>, |
| 45 |
}; |