You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/co2.js
+9-10Lines changed: 9 additions & 10 deletions
Original file line number
Diff line number
Diff line change
@@ -70,27 +70,26 @@ import {
70
70
71
71
classCO2{
72
72
constructor(options){
73
-
this.model=newSustainableWebDesignV3();
73
+
this.model=newSustainableWebDesignV4();
74
74
// Using optional chaining allows an empty object to be passed
75
75
// in without breaking the code.
76
76
if(options?.model==="1byte"){
77
77
this.model=newOneByte();
78
78
}elseif(options?.model==="swd"){
79
-
this.model=newSustainableWebDesignV3();
80
-
if(options?.version===4){
79
+
this.model=newSustainableWebDesignV4();
80
+
if(options?.version===3){
81
+
this.model=newSustainableWebDesignV3();
82
+
}elseif(options?.version===4){
81
83
this.model=newSustainableWebDesignV4();
82
84
}
83
-
}elseif(!options?.model){
84
-
console.warn(`------
85
-
WARNING: We are changing the default estimation model in CO2.js to Sustainable Web Design v4 in the next version (v0.18) of CO2.js. This change will take place in February 2026.
86
-
87
-
If you would like to keep using Sustainable Web Design v3, please make sure to explicitly set it in your code. See https://developers.thegreenwebfoundation.org/co2js/models/#using-sustainable-web-design-model-version-3 for details.
88
-
------
89
-
`);
90
85
}elseif(options?.model){
91
86
thrownewError(
92
87
`"${options.model}" is not a valid model. Please use "1byte" for the OneByte model, and "swd" for the Sustainable Web Design model.\nSee https://developers.thegreenwebfoundation.org/co2js/models/ to learn more about the models available in CO2.js.`
93
88
);
89
+
}elseif(!options?.model&&options?.version){
90
+
thrownewError(
91
+
`"Specified version ${options?.version} but an estimation model is missing. Please specify a model to use for the version you have set.`
0 commit comments