kibana-123
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
37 lines (30 loc) • 861 B
JavaScript
import _ from 'lodash';
export default function PendingRequestList() {
/**
* Queue of pending requests, requests are removed as
* they are processed by fetch.[sourceType]().
* @type {Array}
*/
let queue = [];
queue.getInactive = function (/* strategies */) {
return queue.get.apply(queue, arguments)
.filter(function (req) {
return !req.started;
});
};
queue.getStartable = function (...strategies) {
return queue.get(...strategies).filter(req => req.canStart());
};
queue.get = function (...strategies) {
return queue.filter(function (req) {
let strategyMatch = !strategies.length;
if (!strategyMatch) {
strategyMatch = strategies.some(function (strategy) {
return req.strategy === strategy;
});
}
return strategyMatch;
});
};
return queue;
};