// Subscribe several functions in a single call. Reporter.prototype.subscribeMany = function(funcs) { for (var i = 0; i < funcs.length; ++i) { var func = funcs[i]; this.subscribe(func); } } murom.getMany = function(urls, completionCallback) { var self = this; var results = new Array(urls.length).fill(null); var count = 0; function reportCompletion() { if (++count == urls.length) { if (completionCallback) { completionCallback(results); } } } for (var id in urls) { const url = urls[id]; const urlId = id; murom.get( url, function(contents) { results[urlId] = contents; reportCompletion() }, function(status) { LOG( formatString( "ERROR Could not download URL: '{0}' status: '{1}'", url, status ) ); reportCompletion() } ); } }; murom.import = function(urls, completionCallback) { murom.getMany( urls, function(contents) { for (var id in contents) { eval(contents[id]); } } ); };