SHARE
TWEET

Untitled

a guest Jun 27th, 2019 53 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const fs = require('fs');
  2.  
  3. function fileSize(fileName, cb) {
  4.   if(typeof fileName !== 'string') {
  5.     return process.nextTick(cb, new TypeError('argument should be string'));
  6.   }
  7.  
  8.   fs.stat(fileName, (err, stats) => {
  9.     if(err) {
  10.       return cb(err);
  11.     }
  12.    
  13.     cb(null, stats.size);
  14.   });
  15. }
  16.  
  17. fileSize(1, (err, stats) => {
  18.   if(err) throw err;
  19.  
  20.   console.log(`Size in KB: ${size/1024}`);
  21. });
  22.  
  23. console.log('Hello!');
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top