We can remove these lines as carbonIntensity is set in the function args carbonIntensity = GLOBAL_INTENSITY
Updated:
perByte(bytes, carbonIntensity = GLOBAL_INTENSITY) {
const energyBycomponent = this.energyPerByteByComponent(bytes);
// otherwise when faced with non numeric values throw an error
if (typeof carbonIntensity !== "number") {
throw new Error(
`perByte expects a numeric value or boolean for the carbon intensity value. Received: ${carbonIntensity}`
);
}
const co2ValuesbyComponent = this.co2byComponent(
energyBycomponent,
carbonIntensity
);
// pull out our values…
const co2Values = Object.values(co2ValuesbyComponent);
// so we can return their sum
return co2Values.reduce(
(prevValue, currentValue) => prevValue + currentValue
);
}
https://github.com/thegreenwebfoundation/co2.js/blob/8901d1d5c730240a5023ec1a913bb41dc559d2db/src/sustainable-web-design.js#L100
We can remove these lines as
carbonIntensity
is set in the function argscarbonIntensity = GLOBAL_INTENSITY
Updated: