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

we are a community of more than 2 million smartest coders
registration for
employee referral programs
are now open
get referred to google, amazon, flipkart and more
register now
  
pinned-register now
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}