1 |
|
2 | import { EventEmitter } from "events";
|
3 | import { Stats } from "fs";
|
4 |
|
5 | export = sane;
|
6 |
|
7 | declare function sane(dir: string, options?: sane.Options): sane.Watcher;
|
8 |
|
9 | declare namespace sane {
|
10 | interface Options {
|
11 | glob?: string | string[] | undefined;
|
12 | poll?: boolean | undefined;
|
13 | watchman?: boolean | undefined;
|
14 | fsevents?: boolean | undefined;
|
15 | watcher?: string | undefined;
|
16 | dot?: boolean | undefined;
|
17 | ignored?: AnymatchMatcher | AnymatchMatcher[] | undefined;
|
18 | }
|
19 |
|
20 | const FSEventsWatcher: typeof SaneWatcher;
|
21 | const NodeWatcher: typeof SaneWatcher;
|
22 | const PollWatcher: typeof SaneWatcher;
|
23 | const WatchmanWatcher: typeof SaneWatcher;
|
24 |
|
25 | type Watcher = SaneWatcher;
|
26 |
|
27 | type AnymatchMatcher = string | RegExp | ((...testStrings: string[]) => boolean);
|
28 | }
|
29 |
|
30 | declare class SaneWatcher extends EventEmitter {
|
31 | readonly globs: string[];
|
32 | readonly dot: boolean;
|
33 | readonly ignored: sane.AnymatchMatcher | sane.AnymatchMatcher[];
|
34 | readonly hasIgnore: boolean;
|
35 | readonly root: string;
|
36 |
|
37 | constructor(dir: string, options?: sane.Options);
|
38 | close(callback?: () => void): void;
|
39 |
|
40 | addListener(event: "ready", listener: () => void): this;
|
41 | addListener(event: "error", listener: (error: Error) => void): this;
|
42 | addListener(
|
43 | event: "all",
|
44 | listener: (eventType: AllEventType, path: string, root: string, stat?: Stats) => void,
|
45 | ): this;
|
46 | addListener(event: "add" | "change", listener: (path: string, root: string, stat: Stats) => void): this;
|
47 | addListener(event: "delete", listener: (path: string, root: string) => void): this;
|
48 | on(event: "ready", listener: () => void): this;
|
49 | on(event: "error", listener: (error: Error) => void): this;
|
50 | on(event: "all", listener: (eventType: AllEventType, path: string, root: string, stat?: Stats) => void): this;
|
51 | on(event: "add" | "change", listener: (path: string, root: string, stat: Stats) => void): this;
|
52 | on(event: "delete", listener: (path: string, root: string) => void): this;
|
53 | once(event: "ready", listener: () => void): this;
|
54 | once(event: "error", listener: (error: Error) => void): this;
|
55 | once(event: "all", listener: (eventType: AllEventType, path: string, root: string, stat?: Stats) => void): this;
|
56 | once(event: "add" | "change", listener: (path: string, root: string, stat: Stats) => void): this;
|
57 | once(event: "delete", listener: (path: string, root: string) => void): this;
|
58 | prependListener(event: "ready", listener: () => void): this;
|
59 | prependListener(event: "error", listener: (error: Error) => void): this;
|
60 | prependListener(
|
61 | event: "all",
|
62 | listener: (eventType: AllEventType, path: string, root: string, stat?: Stats) => void,
|
63 | ): this;
|
64 | prependListener(event: "add" | "change", listener: (path: string, root: string, stat: Stats) => void): this;
|
65 | prependListener(event: "delete", listener: (path: string, root: string) => void): this;
|
66 | prependOnceListener(event: "ready", listener: () => void): this;
|
67 | prependOnceListener(event: "error", listener: (error: Error) => void): this;
|
68 | prependOnceListener(
|
69 | event: "all",
|
70 | listener: (eventType: AllEventType, path: string, root: string, stat?: Stats) => void,
|
71 | ): this;
|
72 | prependOnceListener(event: "add" | "change", listener: (path: string, root: string, stat: Stats) => void): this;
|
73 | prependOnceListener(event: "delete", listener: (path: string, root: string) => void): this;
|
74 | removeListener(event: "ready", listener: () => void): this;
|
75 | removeListener(event: "error", listener: (error: Error) => void): this;
|
76 | removeListener(
|
77 | event: "all",
|
78 | listener: (eventType: AllEventType, path: string, root: string, stat?: Stats) => void,
|
79 | ): this;
|
80 | removeListener(event: "add" | "change", listener: (path: string, root: string, stat: Stats) => void): this;
|
81 | removeListener(event: "delete", listener: (path: string, root: string) => void): this;
|
82 | removeAllListeners(event?: EventType): this;
|
83 | // eslint-disable-next-line @typescript-eslint/no-unsafe-function-type
|
84 | listeners(event: EventType): Function[];
|
85 | emit(event: "ready"): boolean;
|
86 | emit(event: "error", error: Error): boolean;
|
87 | emit(event: "all", eventType: AllEventType, path: string, root: string, stat?: Stats): boolean;
|
88 | emit(event: "add" | "change", path: string, root: string, stat: Stats): boolean;
|
89 | emit(event: "delete", path: string, root: string): boolean;
|
90 | eventNames(): EventType[];
|
91 | listenerCount(type: EventType): number;
|
92 | }
|
93 |
|
94 | type EventType = "ready" | "error" | "all" | AllEventType;
|
95 | type AllEventType = "add" | "change" | "delete";
|
96 |
|
\ | No newline at end of file |