@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
36 lines (30 loc) • 889 B
JavaScript
define(function (require) {
return function PendingRequestList() {
var _ = require('lodash');
/**
* Queue of pending requests, requests are removed as
* they are processed by fetch.[sourceType]().
* @type {Array}
*/
var queue = [];
queue.getInactive = function (/* strategies */) {
return queue.get.apply(queue, arguments)
.filter(function (req) {
return !req.started;
});
};
queue.get = function (/* strategies.. */) {
var strategies = _.toArray(arguments);
return queue.filter(function (req) {
var strategyMatch = !strategies.length;
if (!strategyMatch) {
strategyMatch = strategies.some(function (strategy) {
return req.strategy === strategy;
});
}
return strategyMatch && req.canStart();
});
};
return queue;
};
});