check if file is empty javascript fs

Solutions on MaxInterview for check if file is empty javascript fs by the best coders in the world

showing results for - "check if file is empty javascript fs"
Yannick
08 Oct 2017
1if (fs.exists('myfile.txt')) {
2    if (fs.read('myfile.txt').length === 0) {
3        console.log("File is Empty")
4    } else {
5        return JSON.parse(fs.read('myfile.txt'));
6    }
7}