Any idea/tips on how to implement a real time-esh update feature similar to linux TOP command in Node.JS?
My implementation is something like the following:
fs.watchFile(filepath, someFunction);
someFunction(curr, prev){
// Create a child process and run tail command 'tail -f path/to/file'
// Let tail.stdout listen to data event and inside it
process.stdout.write('\033c'); // Reset Terminal every time on file change
process.stdout.write(data);
}Is there any better implementation or package that could assist in implementing this feature? Since watchFile() is slow.
Please note that fs.watch() works only one time, then it never make any callbacks/triggers on file change.
Thanks in advance!