UNPKG

@cloud-carbon-footprint/core

Version:

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

28 lines 1.07 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.StorageEstimator = void 0; const _1 = require("../."); class StorageEstimator { constructor(coefficient) { this.coefficient = coefficient; } estimate(data, region, emissionsFactors, constants) { return data.map((d) => { const estimatedKilowattHours = this.estimateKilowattHours(d.terabyteHours, constants.powerUsageEffectiveness, constants.replicationFactor); return { timestamp: d.timestamp, kilowattHours: estimatedKilowattHours, co2e: (0, _1.estimateCo2)(estimatedKilowattHours, region, emissionsFactors), }; }); } estimateKilowattHours(terabyteHours, powerUsageEffectiveness, replicationFactor = 1) { return ((terabyteHours * this.coefficient * powerUsageEffectiveness * replicationFactor) / 1000); } } exports.StorageEstimator = StorageEstimator; //# sourceMappingURL=StorageEstimator.js.map