EdwardZZZ / articles

工作点滴记录
2 stars 0 forks source link

watch #51

Closed EdwardZZZ closed 2 years ago

EdwardZZZ commented 5 years ago
const fs = require('fs');

fs.watchFile('../testData.json', (curr, prev) => {
    console.log(`the current mtime is: ${curr.mtime}`);
    console.log(`the previous mtime was: ${prev.mtime}`);
});

fs.watch('../', { encoding: 'utf8', recursive: true }, (eventType, filename) => {
      console.log(eventType, filename);
      // 输出: <Buffer ...>
});