UNPKG

@cloud-carbon-footprint/core

Version:

The core logic to get cloud usage data and estimate energy and carbon emissions.

30 lines 1.2 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); class Region { constructor(id, services, emissionsFactors, constants) { this.id = id; this.services = services; this.emissionsFactors = emissionsFactors; this.constants = constants; } async getEstimates(startDate, endDate) { const estimates = await Promise.all(this.services.map(async (service) => { return await service.getEstimates(startDate, endDate, this.id, this.emissionsFactors, this.constants); })); return estimates.reduce((estimatesMap, estimate, i) => { estimatesMap[this.services[i].serviceName] = estimate; return estimatesMap; }, {}); } async getCosts(startDate, endDate) { const estimates = await Promise.all(this.services.map(async (service) => { return await service.getCosts(startDate, endDate, this.id); })); return estimates.reduce((estimatesMap, estimate, i) => { estimatesMap[this.services[i].serviceName] = estimate; return estimatesMap; }, {}); } } exports.default = Region; //# sourceMappingURL=Region.js.map