Created
June 16, 2019 03:44
-
-
Save sysyrin/3dd94f248184a8a2cc22f3e195da0b03 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const fs = require('fs'); | |
function fileSize(fileName, cb) { | |
if(typeof fileName !== 'string') { | |
return process.nextTick(cb, new TypeError('argument should be string')); | |
} | |
fs.stat(fileName, (err, stats) => { | |
if(err) { | |
return cb(err); | |
} | |
cb(null, stats.size); | |
}); | |
} | |
fileSize(1, (err, stats) => { | |
if(err) throw err; | |
console.log(`Size in KB: ${size/1024}`); | |
}); | |
console.log('Hello!'); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment