3 ms·
Here is how I would do it using ToffeeScript (https://github.com/jiangmiao/toffee-script https://github.com/jiangmiao/toffee-script) fs = require 'fs'
by ilaksh 13y ago
Here is how I would do it using ToffeeScript (https://github.com/jiangmiao/toffee-script https://github.com/jiangmiao/toffee-script)
fs = require 'fs'
async = require 'async'
path = require 'path'
module.exports = (dir, cb) ->
err, files = fs.readdir! dir
paths = (path.join dir, file for file in files)
er, stats = async.map! paths, fs.stat
largest = 0
for stat, i in stats
if stat.isFile and stat.size > largest
fname = files[i]
largest = stat.size
cb fname
I use ToffeeScript for everything now, since it makes things much easier to read.