Code like this:
fileArray = ['a.json','b.json','c.json']
dict = {}
fileArray.map (f) ->
fs.readFile f, (err, data) ->
json.parse data, (k, v) ->
dict[k] = v
I want to write the dict object to a file. How can I wait for all asynchronous functions finish?
Or is there any way else to do this?
You can do it manually like this
or you use a async library (for example https://github.com/caolan/async)
Please take care I havent tested this.