UNPKG

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

33 lines (27 loc) 729 B
import _ from 'lodash'; export default function AggResponseBucketsProvider() { function Buckets(aggResp) { aggResp = aggResp || false; this.buckets = aggResp.buckets || []; this.objectMode = _.isPlainObject(this.buckets); if (this.objectMode) { this._keys = _.keys(this.buckets); this.length = this._keys.length; } else { this.length = this.buckets.length; } } Buckets.prototype.forEach = function (fn) { let buckets = this.buckets; if (this.objectMode) { this._keys.forEach(function (key) { fn(buckets[key], key); }); } else { buckets.forEach(function (bucket) { fn(bucket, bucket.key); }); } }; return Buckets; };