27 lines
738 B
JavaScript
27 lines
738 B
JavaScript
'use strict';
|
|
|
|
function MapConfigAdapter(adapters) {
|
|
this.adapters = Array.isArray(adapters) ? adapters : Array.apply(null, arguments);
|
|
}
|
|
|
|
module.exports = MapConfigAdapter;
|
|
|
|
MapConfigAdapter.prototype.getMapConfig = function(user, requestMapConfig, params, context, callback) {
|
|
var self = this;
|
|
var i = 0;
|
|
var tasksLeft = this.adapters.length;
|
|
|
|
function next(err, _requestMapConfig) {
|
|
if (err) {
|
|
return callback(err);
|
|
}
|
|
if (tasksLeft-- === 0) {
|
|
return callback(null, _requestMapConfig);
|
|
}
|
|
var nextAdapter = self.adapters[i++];
|
|
nextAdapter.getMapConfig(user, _requestMapConfig, params, context, next);
|
|
}
|
|
|
|
next(null, requestMapConfig);
|
|
};
|