@spalger/kibana
Version:
Kibana is an open source (Apache Licensed), browser based analytics and search dashboard for Elasticsearch. Kibana is a snap to setup and start using. Kibana strives to be easy to get started with, while also being flexible and powerful, just like Elastic
24 lines (19 loc) • 592 B
JavaScript
define(function (require) {
return function FetchForEachRequestStrategy(Private, Promise) {
var _ = require('lodash');
function forEachStrategy(requests, block) {
block = Promise.method(block);
var sets = [];
requests.forEach(function (req) {
var strategy = req.strategy;
var set = _.find(sets, { 0: strategy });
if (set) set[1].push(req);
else sets.push([strategy, [req]]);
});
return Promise.all(sets.map(function (set) {
return block(set[0], set[1]);
}));
}
return forEachStrategy;
};
});