UNPKG

redis-time-series-ts

Version:
30 lines (29 loc) 1.01 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.MultiRangeResponseRender = void 0; const label_1 = require("../entity/label"); const sample_1 = require("../entity/sample"); class MultiRangeResponseRender { render(response) { const ranges = []; for (const bucket of response) { const key = bucket[0]; const labels = []; for (const label of bucket[1]) { labels.push(new label_1.Label(label[0], label[1])); } const samples = []; for (const sample of bucket[2]) { const sampleValue = Number(sample[1]); samples.push(new sample_1.Sample(key, isNaN(sampleValue) ? 0 : sampleValue, sample[0])); } ranges.push({ key: key, labels: labels, data: samples }); } return ranges; } } exports.MultiRangeResponseRender = MultiRangeResponseRender;