WXL
3 天以前 2cc85c64f1c64a2dbaeae276a3e2ca8420de76b7
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
export function batch(fn: () => void): void;
export function getNumberOfWatchers(): number;
export function watch(filePath: string): Watcher;
export type FSWatcher = import("fs").FSWatcher;
export type EventType = import("./index").EventType;
export type WatcherSet = Set<Watcher>;
export type WatcherEvents = {
    /**
     * change event
     */
    change: (eventType: EventType, filename?: string) => void;
    /**
     * error event
     */
    error: (err: unknown) => void;
};
/**
 * @typedef {object} WatcherEvents
 * @property {(eventType: EventType, filename?: string) => void} change change event
 * @property {(err: unknown) => void} error error event
 */
/**
 * @extends {EventEmitter<{ [K in keyof WatcherEvents]: Parameters<WatcherEvents[K]> }>}
 */
export class Watcher extends EventEmitter<{
    /**
     * change event
     */
    change: [
        eventType: import("./index").EventType,
        filename?: string | undefined,
    ];
    /**
     * error event
     */
    error: [err: unknown];
}> {
    constructor();
    close(): void;
}
/**
 * @param {FSWatcher} watcher watcher
 * @param {string} filePath a file path
 * @param {(type: "rename" | "change", filename: string) => void} handleChangeEvent function to handle change
 * @returns {(type: "rename" | "change", filename: string) => void} handler of change event
 */
export function createHandleChangeEvent(
    watcher: FSWatcher,
    filePath: string,
    handleChangeEvent: (type: "rename" | "change", filename: string) => void,
): (type: "rename" | "change", filename: string) => void;
export const watcherLimit: number;
import { EventEmitter } from "events";