Skip to content

Commit

Permalink
allow for SWDM version change
Browse files Browse the repository at this point in the history
  • Loading branch information
fershad committed May 27, 2024
1 parent 91b73b1 commit 15e33a5
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/co2.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@

import OneByte from "./1byte.js";
import SustainableWebDesignV3 from "./sustainable-web-design-v3.js";
import SustainableWebDesignV4 from "./sustainable-web-design-v4.js";

import {
GLOBAL_GRID_INTENSITY,
Expand All @@ -77,6 +78,9 @@ class CO2 {
this.model = new OneByte();
} else if (options?.model === "swd") {
this.model = new SustainableWebDesignV3();
if (options?.version === 4) {
this.model = new SustainableWebDesignV4();
}
} else if (options?.model) {
throw new Error(
`"${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.`
Expand Down
1 change: 1 addition & 0 deletions src/sustainable-web-design-v3.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ class SustainableWebDesign {
constructor(options) {
this.allowRatings = true;
this.options = options;
this.version = 3;
}

/**
Expand Down
1 change: 1 addition & 0 deletions src/sustainable-web-design-v4.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ const {
class SustainableWebDesign {
constructor(options) {
this.options = options;
this.version = 4;
}

/**
Expand Down

0 comments on commit 15e33a5

Please sign in to comment.