How to access the arguments of methods , ... of the callback? fs.readfs.stat
For example, if I want to process a file by its size, the following code fragment (coffeeScript)
filename = "./test1.txt"
fs.stat filename, (err, stats) ->
data = filename:filename,size:stats.size
console.log data
filename = "./test2.txt"
prints
{ filename: './test2.txt', size: 5 }
the file name is set to "./test2.txt". If I process / read a file using the file name variable in the callback fs.stat, it will use test2.txtone that is not intended.
What I expect to see in the callback
{ filename: './test1.txt', size: 5 }
source
share