Right now, while we have the Sustainable Web Design module, we default using to the earlier created 1byte model for CO2 calculations.
So when you do this:
import { CO2 } from '@tgwf/co2'
const calc = new CO2()
// calculate transfer
const basicTransferResult = calc.perbyte(TRANSFER_IN_BYTES)
...you're using the 1byte model from the Shift Project.
Making the change.
We need to change this code so default model is no longer the Onebyte one, and instead the SWD one:
class CO2 {
constructor(options) {
this.options = options;
// default model
this.model = new OneByte();
if (options) {
this.model = new options.model();
}
}
This would mean when we import the CO2 module, we can calculate web pages easily, not just do basis transfer calculations.
import { CO2 } from '@tgwf/co2'
const calc = new CO2()
// calculate transfer
const basicTransferResult = calc.perbyte(TRANSFER_IN_BYTES)
// new: calculate the result for a web page, including caching assumptions in the SWD model
const webPageResult = calc.energyPerVisit(WEBSITE_SIZE_IN_BYTES)
This will have the effect of increasing carbon numbers slightly but it also means we can get a breakdown of where the emissions are assumed to happen.
Todo
[ ] Switch default model to SWD one
[ ] Update tests to reflect increased numbers
[ ] Update docs and code examples to refer to SWD model by default
Right now, while we have the Sustainable Web Design module, we default using to the earlier created 1byte model for CO2 calculations.
So when you do this:
...you're using the 1byte model from the Shift Project.
Making the change.
We need to change this code so default model is no longer the
Onebyte
one, and instead the SWD one:This would mean when we import the CO2 module, we can calculate web pages easily, not just do basis transfer calculations.
This will have the effect of increasing carbon numbers slightly but it also means we can get a breakdown of where the emissions are assumed to happen.
Todo