'change' 事件

    当监视的目录或文件中的某些内容发生更改时触发。 在 fs.watch() 中查看更多详细信息。

    • eventType <string> The type of change event that has occurred
    • filename <string> | <Buffer> The filename that changed (if relevant/available)

    Emitted when something changes in a watched directory or file. See more details in fs.watch().

    The filename argument may not be provided depending on operating system support. If filename is provided, it will be provided as a <Buffer> if fs.watch() is called with its encoding option set to 'buffer', otherwise filename will be a UTF-8 string.

    import { watch } from 'node:fs';
    // Example when handled through fs.watch() listener
    watch('./tmp', { encoding: 'buffer' }, (eventType, filename) => {
      if (filename) {
        // Prints: <Buffer ...>