UNPKG

@cloud-carbon-footprint/core

Version:

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

24 lines 965 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const _1 = require("../."); class NetworkingEstimator { constructor(coefficient) { this.coefficient = coefficient; } estimate(data, region, emissionsFactors, constants) { return data.map((data) => { const estimatedKilowattHours = this.estimateKilowattHours(data.gigabytes, constants.powerUsageEffectiveness); const estimatedCO2Emissions = (0, _1.estimateCo2)(estimatedKilowattHours, region, emissionsFactors); return { timestamp: data.timestamp, kilowattHours: estimatedKilowattHours, co2e: estimatedCO2Emissions, }; }); } estimateKilowattHours(gigaBytes, powerUsageEffectiveness) { return gigaBytes * this.coefficient * powerUsageEffectiveness; } } exports.default = NetworkingEstimator; //# sourceMappingURL=NetworkingEstimator.js.map