Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

check if file is empty javascript fs

if (fs.exists('myfile.txt')) {
    if (fs.read('myfile.txt').length === 0) {
        console.log("File is Empty")
    } else {
        return JSON.parse(fs.read('myfile.txt'));
    }
}
Comment

PREVIOUS NEXT
Code Example
Javascript :: typescript css variables 
Javascript :: how to set/get cookie in JavaScript 
Javascript :: Installation failed, reverting ./composer.json and ./composer.lock to their original content. 
Javascript :: useref not defined : error 
Javascript :: select html react 
Javascript :: install gulp ubuntu 20.04 
Javascript :: exceljs read file 
Javascript :: sql json_extract 
Javascript :: ionic angular change page route 
Javascript :: javascript remove all event listeners 
Javascript :: jquery validator no space 
Javascript :: how to call datetime in javascript 
Javascript :: angular call function every x seconds 
Javascript :: convert milliseconds to minutes and seconds javascript 
Javascript :: js last word in a string 
Javascript :: splidejs autoscroll 
Javascript :: joi schema for confirm password 
Javascript :: object delete with id filter javascript 
Javascript :: You need to authorize this machine using `npm adduser` 
Javascript :: flatten in js without lodash 
Javascript :: get the integer after decimal in javascript 
Javascript :: nuxt js if is client 
Javascript :: chart js x axis start at 0 
Javascript :: how to run angular application in visual studio code 
Javascript :: redux append to an array 
Javascript :: moment get week day 
Javascript :: Deleting all white spaces in a string 
Javascript :: prop type for ref in react js 
Javascript :: react counter input 
Javascript :: download canvas js 
ADD CONTENT
Topic
Content
Source link
Name
5+4 =