We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent e06e67c commit f9731fcCopy full SHA for f9731fc
2 files changed
JavaScript/6-watch.js
@@ -3,7 +3,7 @@
3
const fs = require('fs');
4
5
const watch = (path) => {
6
- const watcher = fs.watch(path, (event, file) => {
+ fs.watch(path, (event, file) => {
7
console.dir({ event, file });
8
});
9
};
JavaScript/7-autoreload.js
@@ -0,0 +1,26 @@
1
+'use strict';
2
+
+const fs = require('fs');
+let buffer;
+const load = (path) => {
+ fs.readFile(path, (err, data) => {
+ if (err) throw err;
10
+ buffer = data;
11
+ console.log('\x1Bc');
12
+ console.log('Buffer length: ' + buffer.length);
13
+ console.log(buffer.toString());
14
+ });
15
+};
16
17
+const watch = (path) => {
18
19
+ console.dir({ event, file });
20
+ load(path);
21
22
23
24
+const path = './1-readFileSync.js';
25
+load(path);
26
+watch(path);
0 commit comments