@tgwf/co2 0.13.7 → 0.13.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (38) hide show
  1. package/.all-contributorsrc +10 -0
  2. package/CHANGELOG.md +19 -4
  3. package/README.md +2 -1
  4. package/data/output/average-intensities.js +12 -12
  5. package/data/output/average-intensities.json +12 -12
  6. package/dist/cjs/co2.js +9 -9
  7. package/dist/cjs/co2.js.map +1 -1
  8. package/dist/cjs/data/average-intensities.min.js +1 -1
  9. package/dist/cjs/data/average-intensities.min.js.map +2 -2
  10. package/dist/cjs/helpers/index.js +6 -6
  11. package/dist/cjs/helpers/index.js.map +2 -2
  12. package/dist/cjs/sustainable-web-design.js +6 -6
  13. package/dist/cjs/sustainable-web-design.js.map +2 -2
  14. package/dist/data/functions/generate_average_co2.d.ts +2 -0
  15. package/dist/data/functions/generate_average_co2.d.ts.map +1 -0
  16. package/dist/data/functions/generate_marginal_co2.d.ts +2 -0
  17. package/dist/data/functions/generate_marginal_co2.d.ts.map +1 -0
  18. package/dist/data/output/average-intensities.d.ts +231 -0
  19. package/dist/data/output/average-intensities.d.ts.map +1 -0
  20. package/dist/data/output/marginal-intensities-2021.d.ts +243 -0
  21. package/dist/data/output/marginal-intensities-2021.d.ts.map +1 -0
  22. package/dist/data/utils/getCountryCodes.d.ts +3 -0
  23. package/dist/data/utils/getCountryCodes.d.ts.map +1 -0
  24. package/dist/data/utils/mapCountries.d.ts +3 -0
  25. package/dist/data/utils/mapCountries.d.ts.map +1 -0
  26. package/dist/data/utils/parseCSVRow.d.ts +8 -0
  27. package/dist/data/utils/parseCSVRow.d.ts.map +1 -0
  28. package/dist/esm/co2.js +11 -11
  29. package/dist/esm/data/average-intensities.min.js +1 -1
  30. package/dist/esm/helpers/index.js +6 -6
  31. package/dist/esm/sustainable-web-design.js +6 -6
  32. package/dist/iife/index.js +16 -16
  33. package/dist/iife/index.js.map +2 -2
  34. package/package.json +1 -1
  35. package/src/co2.js +9 -9
  36. package/src/data/average-intensities.min.js +1 -1
  37. package/src/helpers/index.js +6 -6
  38. package/src/sustainable-web-design.js +6 -6
@@ -122,6 +122,16 @@
122
122
  "contributions": [
123
123
  "code"
124
124
  ]
125
+ },
126
+ {
127
+ "login": "p-gerard",
128
+ "name": "p-gerard",
129
+ "avatar_url": "https://avatars.githubusercontent.com/u/97036756?v=4",
130
+ "profile": "https://github.com/p-gerard",
131
+ "contributions": [
132
+ "bug",
133
+ "code"
134
+ ]
125
135
  }
126
136
  ],
127
137
  "contributorsPerLine": 7,
package/CHANGELOG.md CHANGED
@@ -18,6 +18,21 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
18
18
 
19
19
  # Released
20
20
 
21
+ ## [0.13.8] - 2023-10-09
22
+
23
+ - Fix: Properly use value of 0 for system segments and variables in the perByteTrace and perVisitTrace functions.
24
+ - Automated monthly update of annual average grid intensity data.
25
+
26
+ ## [0.13.7] - 2023-09-13
27
+
28
+ - Automated monthly update of annual average grid intensity data.
29
+
30
+ ## [0.13.6] - 2023-08-08
31
+
32
+ - Automated monthly update of annual average grid intensity data.
33
+ - Create FUNDING.yml to allow sponsor contribution to this project.
34
+ - Store segment flag on CO2 instance, not models.
35
+
21
36
  ## [0.13.5] - 2023-07-5
22
37
 
23
38
  ### Changed
@@ -54,8 +69,8 @@ In PR #135 there were significant changes made to how average annual grid intens
54
69
 
55
70
  - Updated average annual grid intensities to include 2022 values from Ember.
56
71
  - Changed the functions to generate average grid intensities to:
57
- - Fetch data directly from Ember's API.
58
- - Get the *latest* annual average values for each country/region.
72
+ - Fetch data directly from Ember's API.
73
+ - Get the _latest_ annual average values for each country/region.
59
74
  - Renamed the average grid intensities export file.
60
75
 
61
76
  ## [0.12.2] - 2023-03-01
@@ -120,7 +135,7 @@ In PR #135 there were significant changes made to how average annual grid intens
120
135
 
121
136
  ### Changed
122
137
 
123
- - Changed the default model for transfer based CO2 calculations from the _1byte_ model to the _Sustainable Web Design_ model instead. See https://developers.thegreenwebfoundation.org/co2js/models/ for guidance on the differences and how to migrate between them. See [#94 for more](https://github.com/thegreenwebfoundation/co2.js/issues/94).
138
+ - Changed the default model for transfer based CO2 calculations from the _1byte_ model to the _Sustainable Web Design_ model instead. See <https://developers.thegreenwebfoundation.org/co2js/models/> for guidance on the differences and how to migrate between them. See [#94 for more](https://github.com/thegreenwebfoundation/co2.js/issues/94).
124
139
  - Updated our release commands to generate and format the carbon intensity data as part of the release process.
125
140
 
126
141
  ## [0.10.4] - 2022-08-12
@@ -212,7 +227,7 @@ This release used a version bump as previously we had released v0.10.0 under a p
212
227
 
213
228
  ### Removed
214
229
 
215
- - Extracted sqlite usage and dependencies into a separate module, `url2green`. This means you no longer need to compile SQLite on install.
230
+ - Extracted sqlite usage and dependencies into a separate module, `url2green`. This means you no longer need to compile SQLite on install.
216
231
 
217
232
  ## [0.5.0] - 2020-03-03
218
233
 
package/README.md CHANGED
@@ -1,7 +1,7 @@
1
1
  # CO2.js
2
2
 
3
3
  <!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section -->
4
- [![All Contributors](https://img.shields.io/badge/all_contributors-12-orange.svg?style=flat-square)](#contributors-)
4
+ [![All Contributors](https://img.shields.io/badge/all_contributors-13-orange.svg?style=flat-square)](#contributors-)
5
5
  <!-- ALL-CONTRIBUTORS-BADGE:END -->
6
6
 
7
7
  <img src="https://github.com/thegreenwebfoundation/co2.js/actions/workflows/unittests.yml/badge.svg" />
@@ -145,6 +145,7 @@ See LICENCE for more.
145
145
  <td align="center" valign="top" width="14.28%"><a href="https://www.intersectionalenvironmentalist.com/"><img src="https://avatars.githubusercontent.com/u/1530684?v=4?s=100" width="100px;" alt="Piper"/><br /><sub><b>Piper</b></sub></a><br /><a href="https://github.com/thegreenwebfoundation/co2.js/commits?author=piperchester" title="Code">💻</a></td>
146
146
  <td align="center" valign="top" width="14.28%"><a href="https://vasquezruiz.com/"><img src="https://avatars.githubusercontent.com/u/108420?v=4?s=100" width="100px;" alt="Raymundo Vásquez Ruiz"/><br /><sub><b>Raymundo Vásquez Ruiz</b></sub></a><br /><a href="https://github.com/thegreenwebfoundation/co2.js/commits?author=raymundovr" title="Code">💻</a></td>
147
147
  <td align="center" valign="top" width="14.28%"><a href="https://greengumption.co.uk/"><img src="https://avatars.githubusercontent.com/u/26165947?v=4?s=100" width="100px;" alt="JamieB"/><br /><sub><b>JamieB</b></sub></a><br /><a href="https://github.com/thegreenwebfoundation/co2.js/commits?author=JamieBeevor" title="Code">💻</a></td>
148
+ <td align="center" valign="top" width="14.28%"><a href="https://github.com/p-gerard"><img src="https://avatars.githubusercontent.com/u/97036756?v=4?s=100" width="100px;" alt="p-gerard"/><br /><sub><b>p-gerard</b></sub></a><br /><a href="https://github.com/thegreenwebfoundation/co2.js/issues?q=author%3Ap-gerard" title="Bug reports">🐛</a> <a href="https://github.com/thegreenwebfoundation/co2.js/commits?author=p-gerard" title="Code">💻</a></td>
148
149
  </tr>
149
150
  </tbody>
150
151
  </table>
@@ -63,8 +63,8 @@ const data = {
63
63
  EST: 464.03,
64
64
  SWZ: 189.19,
65
65
  ETH: 25.19,
66
- EU: 277.19,
67
- EUROPE: 296.45,
66
+ EU: 276.5,
67
+ EUROPE: 297.16,
68
68
  FLK: 500,
69
69
  FRO: 428.57,
70
70
  FJI: 289.47,
@@ -72,12 +72,12 @@ const data = {
72
72
  FRA: 84.82,
73
73
  GUF: 254.72,
74
74
  PYF: 471.43,
75
- G20: 442.38,
76
- G7: 343.92,
75
+ G20: 442.62,
76
+ G7: 344.29,
77
77
  GAB: 397.38,
78
78
  GMB: 700,
79
79
  GEO: 134.83,
80
- DEU: 384.83,
80
+ DEU: 385.38,
81
81
  GHA: 361.2,
82
82
  GRC: 343.82,
83
83
  GRL: 133.33,
@@ -146,12 +146,12 @@ const data = {
146
146
  NIC: 354.21,
147
147
  NER: 622.22,
148
148
  NGA: 368.11,
149
- "NORTH AMERICA": 336.01,
149
+ "NORTH AMERICA": 336.68,
150
150
  PRK: 157.79,
151
151
  MKD: 529.33,
152
152
  NOR: 28.82,
153
153
  OCEANIA: 449.71,
154
- OECD: 340.95,
154
+ OECD: 341.2,
155
155
  OMN: 488.27,
156
156
  PAK: 344.16,
157
157
  PSE: 465.12,
@@ -183,7 +183,7 @@ const data = {
183
183
  SVN: 237.38,
184
184
  SLB: 727.27,
185
185
  SOM: 634.15,
186
- ZAF: 708.19,
186
+ ZAF: 708.21,
187
187
  KOR: 437.6,
188
188
  SSD: 684.21,
189
189
  ESP: 217.37,
@@ -193,7 +193,7 @@ const data = {
193
193
  SWE: 45.08,
194
194
  CHE: 45.62,
195
195
  SYR: 541.17,
196
- TWN: 561.02,
196
+ TWN: 560.98,
197
197
  TJK: 83.63,
198
198
  TZA: 366.75,
199
199
  THA: 501.57,
@@ -206,10 +206,10 @@ const data = {
206
206
  TKM: 490.19,
207
207
  TCA: 703.7,
208
208
  UGA: 52.27,
209
- UKR: 187.06,
209
+ UKR: 230.89,
210
210
  ARE: 407.98,
211
211
  GBR: 261.24,
212
- USA: 367.26,
212
+ USA: 368.1,
213
213
  URY: 114.89,
214
214
  UZB: 505.41,
215
215
  VUT: 571.43,
@@ -217,7 +217,7 @@ const data = {
217
217
  VNM: 386.49,
218
218
  VGB: 714.29,
219
219
  VIR: 685.71,
220
- WORLD: 437.26,
220
+ WORLD: 437.67,
221
221
  YEM: 543.91,
222
222
  ZMB: 84.7,
223
223
  ZWE: 392.28,
@@ -387,13 +387,13 @@
387
387
  "country_code": "",
388
388
  "country_or_region": "EU",
389
389
  "year": 2022,
390
- "emissions_intensity_gco2_per_kwh": 277.19
390
+ "emissions_intensity_gco2_per_kwh": 276.5
391
391
  },
392
392
  "Europe": {
393
393
  "country_code": "",
394
394
  "country_or_region": "Europe",
395
395
  "year": 2022,
396
- "emissions_intensity_gco2_per_kwh": 296.45
396
+ "emissions_intensity_gco2_per_kwh": 297.16
397
397
  },
398
398
  "FLK": {
399
399
  "country_code": "FLK",
@@ -441,13 +441,13 @@
441
441
  "country_code": "",
442
442
  "country_or_region": "G20",
443
443
  "year": 2022,
444
- "emissions_intensity_gco2_per_kwh": 442.38
444
+ "emissions_intensity_gco2_per_kwh": 442.62
445
445
  },
446
446
  "G7": {
447
447
  "country_code": "",
448
448
  "country_or_region": "G7",
449
449
  "year": 2022,
450
- "emissions_intensity_gco2_per_kwh": 343.92
450
+ "emissions_intensity_gco2_per_kwh": 344.29
451
451
  },
452
452
  "GAB": {
453
453
  "country_code": "GAB",
@@ -471,7 +471,7 @@
471
471
  "country_code": "DEU",
472
472
  "country_or_region": "Germany",
473
473
  "year": 2022,
474
- "emissions_intensity_gco2_per_kwh": 384.83
474
+ "emissions_intensity_gco2_per_kwh": 385.38
475
475
  },
476
476
  "GHA": {
477
477
  "country_code": "GHA",
@@ -885,7 +885,7 @@
885
885
  "country_code": "",
886
886
  "country_or_region": "North America",
887
887
  "year": 2022,
888
- "emissions_intensity_gco2_per_kwh": 336.01
888
+ "emissions_intensity_gco2_per_kwh": 336.68
889
889
  },
890
890
  "PRK": {
891
891
  "country_code": "PRK",
@@ -915,7 +915,7 @@
915
915
  "country_code": "",
916
916
  "country_or_region": "OECD",
917
917
  "year": 2022,
918
- "emissions_intensity_gco2_per_kwh": 340.95
918
+ "emissions_intensity_gco2_per_kwh": 341.2
919
919
  },
920
920
  "OMN": {
921
921
  "country_code": "OMN",
@@ -1107,7 +1107,7 @@
1107
1107
  "country_code": "ZAF",
1108
1108
  "country_or_region": "South Africa",
1109
1109
  "year": 2022,
1110
- "emissions_intensity_gco2_per_kwh": 708.19
1110
+ "emissions_intensity_gco2_per_kwh": 708.21
1111
1111
  },
1112
1112
  "KOR": {
1113
1113
  "country_code": "KOR",
@@ -1167,7 +1167,7 @@
1167
1167
  "country_code": "TWN",
1168
1168
  "country_or_region": "Taiwan",
1169
1169
  "year": 2022,
1170
- "emissions_intensity_gco2_per_kwh": 561.02
1170
+ "emissions_intensity_gco2_per_kwh": 560.98
1171
1171
  },
1172
1172
  "TJK": {
1173
1173
  "country_code": "TJK",
@@ -1245,7 +1245,7 @@
1245
1245
  "country_code": "UKR",
1246
1246
  "country_or_region": "Ukraine",
1247
1247
  "year": 2022,
1248
- "emissions_intensity_gco2_per_kwh": 187.06
1248
+ "emissions_intensity_gco2_per_kwh": 230.89
1249
1249
  },
1250
1250
  "ARE": {
1251
1251
  "country_code": "ARE",
@@ -1263,7 +1263,7 @@
1263
1263
  "country_code": "USA",
1264
1264
  "country_or_region": "United States",
1265
1265
  "year": 2022,
1266
- "emissions_intensity_gco2_per_kwh": 367.26
1266
+ "emissions_intensity_gco2_per_kwh": 368.1
1267
1267
  },
1268
1268
  "URY": {
1269
1269
  "country_code": "URY",
@@ -1311,7 +1311,7 @@
1311
1311
  "country_code": "",
1312
1312
  "country_or_region": "World",
1313
1313
  "year": 2022,
1314
- "emissions_intensity_gco2_per_kwh": 437.26
1314
+ "emissions_intensity_gco2_per_kwh": 437.67
1315
1315
  },
1316
1316
  "YEM": {
1317
1317
  "country_code": "YEM",
package/dist/cjs/co2.js CHANGED
@@ -68,10 +68,10 @@ See https://developers.thegreenwebfoundation.org/co2js/methods/ to learn more ab
68
68
  bytes,
69
69
  gridIntensity: {
70
70
  description: "The grid intensity (grams per kilowatt-hour) used to calculate this CO2 estimate.",
71
- network: ((_b = (_a = adjustments == null ? void 0 : adjustments.gridIntensity) == null ? void 0 : _a.network) == null ? void 0 : _b.value) || import_constants.GLOBAL_GRID_INTENSITY,
72
- dataCenter: green ? import_constants.RENEWABLES_GRID_INTENSITY : ((_d = (_c = adjustments == null ? void 0 : adjustments.gridIntensity) == null ? void 0 : _c.dataCenter) == null ? void 0 : _d.value) || import_constants.GLOBAL_GRID_INTENSITY,
71
+ network: ((_b = (_a = adjustments == null ? void 0 : adjustments.gridIntensity) == null ? void 0 : _a.network) == null ? void 0 : _b.value) ?? import_constants.GLOBAL_GRID_INTENSITY,
72
+ dataCenter: green ? import_constants.RENEWABLES_GRID_INTENSITY : ((_d = (_c = adjustments == null ? void 0 : adjustments.gridIntensity) == null ? void 0 : _c.dataCenter) == null ? void 0 : _d.value) ?? import_constants.GLOBAL_GRID_INTENSITY,
73
73
  production: import_constants.GLOBAL_GRID_INTENSITY,
74
- device: ((_f = (_e = adjustments == null ? void 0 : adjustments.gridIntensity) == null ? void 0 : _e.device) == null ? void 0 : _f.value) || import_constants.GLOBAL_GRID_INTENSITY
74
+ device: ((_f = (_e = adjustments == null ? void 0 : adjustments.gridIntensity) == null ? void 0 : _e.device) == null ? void 0 : _f.value) ?? import_constants.GLOBAL_GRID_INTENSITY
75
75
  }
76
76
  }
77
77
  };
@@ -91,14 +91,14 @@ See https://developers.thegreenwebfoundation.org/co2js/methods/ to learn more ab
91
91
  bytes,
92
92
  gridIntensity: {
93
93
  description: "The grid intensity (grams per kilowatt-hour) used to calculate this CO2 estimate.",
94
- network: ((_c = (_b = adjustments == null ? void 0 : adjustments.gridIntensity) == null ? void 0 : _b.network) == null ? void 0 : _c.value) || import_constants.GLOBAL_GRID_INTENSITY,
95
- dataCenter: green ? import_constants.RENEWABLES_GRID_INTENSITY : ((_e = (_d = adjustments == null ? void 0 : adjustments.gridIntensity) == null ? void 0 : _d.dataCenter) == null ? void 0 : _e.value) || import_constants.GLOBAL_GRID_INTENSITY,
94
+ network: ((_c = (_b = adjustments == null ? void 0 : adjustments.gridIntensity) == null ? void 0 : _b.network) == null ? void 0 : _c.value) ?? import_constants.GLOBAL_GRID_INTENSITY,
95
+ dataCenter: green ? import_constants.RENEWABLES_GRID_INTENSITY : ((_e = (_d = adjustments == null ? void 0 : adjustments.gridIntensity) == null ? void 0 : _d.dataCenter) == null ? void 0 : _e.value) ?? import_constants.GLOBAL_GRID_INTENSITY,
96
96
  production: import_constants.GLOBAL_GRID_INTENSITY,
97
- device: ((_g = (_f = adjustments == null ? void 0 : adjustments.gridIntensity) == null ? void 0 : _f.device) == null ? void 0 : _g.value) || import_constants.GLOBAL_GRID_INTENSITY
97
+ device: ((_g = (_f = adjustments == null ? void 0 : adjustments.gridIntensity) == null ? void 0 : _f.device) == null ? void 0 : _g.value) ?? import_constants.GLOBAL_GRID_INTENSITY
98
98
  },
99
- dataReloadRatio: (adjustments == null ? void 0 : adjustments.dataReloadRatio) || 0.02,
100
- firstVisitPercentage: (adjustments == null ? void 0 : adjustments.firstVisitPercentage) || 0.75,
101
- returnVisitPercentage: (adjustments == null ? void 0 : adjustments.returnVisitPercentage) || 0.25
99
+ dataReloadRatio: (adjustments == null ? void 0 : adjustments.dataReloadRatio) ?? 0.02,
100
+ firstVisitPercentage: (adjustments == null ? void 0 : adjustments.firstVisitPercentage) ?? 0.75,
101
+ returnVisitPercentage: (adjustments == null ? void 0 : adjustments.returnVisitPercentage) ?? 0.25
102
102
  }
103
103
  };
104
104
  } else {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/co2.js"],
4
- "sourcesContent": ["\"use strict\";\n\n/**\n * @typedef {Object} CO2EstimateTraceResultPerByte\n * @property {number} co2 - The CO2 estimate in grams/kilowatt-hour\n * @property {boolean} green - Whether the domain is green or not\n * @property {TraceResultVariables} variables - The variables used to calculate the CO2 estimate\n */\n\n/**\n * @typedef {Object} CO2EstimateTraceResultPerVisit\n * @property {number} co2 - The CO2 estimate in grams/kilowatt-hour\n * @property {boolean} green - Whether the domain is green or not\n * @property {TraceResultVariables} variables - The variables used to calculate the CO2 estimate\n */\n\n/**\n * @typedef {Object} TraceResultVariablesPerByte\n * @property {GridIntensityVariables} gridIntensity - The grid intensity related variables\n */\n/**\n * @typedef {Object} TraceResultVariablesPerVisit\n * @property {GridIntensityVariables} gridIntensity - The grid intensity related variables\n * @property {number} dataReloadRatio - What percentage of a page is reloaded on each subsequent page view\n * @property {number} firstVisitPercentage - What percentage of visits are loading this page for subsequent times\n * @property {number} returnVisitPercentage - What percentage of visits are loading this page for the second or more time\n */\n\n/**\n * @typedef {Object} GridIntensityVariables\n * @property {string} description - The description of the variables\n * @property {number} network - The network grid intensity set by the user or the default\n * @property {number} dataCenter - The data center grid intensity set by the user or the default\n * @property {number} device - The device grid intensity set by the user or the default\n * @property {number} production - The production grid intensity set by the user or the default\n */\n\nimport OneByte from \"./1byte.js\";\nimport SustainableWebDesign from \"./sustainable-web-design.js\";\n\nimport {\n GLOBAL_GRID_INTENSITY,\n RENEWABLES_GRID_INTENSITY,\n} from \"./constants/index.js\";\nimport { parseOptions } from \"./helpers/index.js\";\n\nclass CO2 {\n constructor(options) {\n this.model = new SustainableWebDesign();\n // Using optional chaining allows an empty object to be passed\n // in without breaking the code.\n if (options?.model === \"1byte\") {\n this.model = new OneByte();\n } else if (options?.model === \"swd\") {\n this.model = new SustainableWebDesign();\n } else if (options?.model) {\n throw new Error(\n `\"${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.`\n );\n }\n\n /** @private */\n this._segment = options?.results === \"segment\";\n }\n\n /**\n * Accept a figure in bytes for data transfer, and a boolean for whether\n * the domain shows as 'green', and return a CO2 figure for energy used to shift the corresponding\n * the data transfer.\n *\n * @param {number} bytes\n * @param {boolean} green\n * @return {number} the amount of CO2 in grammes\n */\n perByte(bytes, green = false) {\n return this.model.perByte(bytes, green, this._segment);\n }\n\n /**\n * Accept a figure in bytes for data transfer, and a boolean for whether\n * the domain shows as 'green', and return a CO2 figure for energy used to shift the corresponding\n * the data transfer.\n *\n * @param {number} bytes\n * @param {boolean} green\n * @return {number} the amount of CO2 in grammes\n */\n perVisit(bytes, green = false) {\n if (this.model?.perVisit) {\n return this.model.perVisit(bytes, green, this._segment);\n } else {\n throw new Error(\n `The perVisit() method is not supported in the model you are using. Try using perByte() instead.\\nSee https://developers.thegreenwebfoundation.org/co2js/methods/ to learn more about the methods available in CO2.js.`\n );\n }\n }\n\n /**\n * Accept a figure in bytes for data transfer, a boolean for whether\n * the domain shows as 'green', and an options object.\n * Returns an object containing CO2 figure, green boolean, and object of the variables used in calculating the CO2 figure.\n *\n * @param {number} bytes\n * @param {boolean} green\n * @param {Object} options\n * @return {CO2EstimateTraceResultPerByte} the amount of CO2 in grammes\n */\n perByteTrace(bytes, green = false, options = {}) {\n let adjustments = {};\n if (options) {\n // If there are options, parse them and add them to the model.\n adjustments = parseOptions(options);\n }\n return {\n co2: this.model.perByte(bytes, green, this._segment, adjustments),\n green,\n variables: {\n description:\n \"Below are the variables used to calculate this CO2 estimate.\",\n bytes,\n gridIntensity: {\n description:\n \"The grid intensity (grams per kilowatt-hour) used to calculate this CO2 estimate.\",\n network:\n adjustments?.gridIntensity?.network?.value || GLOBAL_GRID_INTENSITY,\n dataCenter: green\n ? RENEWABLES_GRID_INTENSITY\n : adjustments?.gridIntensity?.dataCenter?.value ||\n GLOBAL_GRID_INTENSITY,\n production: GLOBAL_GRID_INTENSITY,\n device:\n adjustments?.gridIntensity?.device?.value || GLOBAL_GRID_INTENSITY,\n },\n },\n };\n }\n\n /**\n * Accept a figure in bytes for data transfer, a boolean for whether\n * the domain shows as 'green', and an options object.\n * Returns an object containing CO2 figure, green boolean, and object of the variables used in calculating the CO2 figure.\n *\n * @param {number} bytes\n * @param {boolean} green\n * @param {Object} options\n * @return {CO2EstimateTraceResultPerVisit} the amount of CO2 in grammes\n */\n perVisitTrace(bytes, green = false, options = {}) {\n if (this.model?.perVisit) {\n let adjustments = {};\n if (options) {\n // If there are options, parse them and add them to the model.\n adjustments = parseOptions(options);\n }\n\n return {\n co2: this.model.perVisit(bytes, green, this._segment, adjustments),\n green,\n variables: {\n description:\n \"Below are the variables used to calculate this CO2 estimate.\",\n bytes,\n gridIntensity: {\n description:\n \"The grid intensity (grams per kilowatt-hour) used to calculate this CO2 estimate.\",\n network:\n adjustments?.gridIntensity?.network?.value ||\n GLOBAL_GRID_INTENSITY,\n dataCenter: green\n ? RENEWABLES_GRID_INTENSITY\n : adjustments?.gridIntensity?.dataCenter?.value ||\n GLOBAL_GRID_INTENSITY,\n production: GLOBAL_GRID_INTENSITY,\n device:\n adjustments?.gridIntensity?.device?.value ||\n GLOBAL_GRID_INTENSITY,\n },\n dataReloadRatio: adjustments?.dataReloadRatio || 0.02,\n firstVisitPercentage: adjustments?.firstVisitPercentage || 0.75,\n returnVisitPercentage: adjustments?.returnVisitPercentage || 0.25,\n },\n };\n } else {\n throw new Error(\n `The perVisitDetailed() method is not supported in the model you are using. Try using perByte() instead.\\nSee https://developers.thegreenwebfoundation.org/co2js/methods/ to learn more about the methods available in CO2.js.`\n );\n }\n }\n\n perDomain(pageXray, greenDomains) {\n const co2PerDomain = [];\n for (let domain of Object.keys(pageXray.domains)) {\n let co2;\n if (greenDomains && greenDomains.indexOf(domain) > -1) {\n co2 = this.perByte(pageXray.domains[domain].transferSize, true);\n } else {\n co2 = this.perByte(pageXray.domains[domain].transferSize);\n }\n co2PerDomain.push({\n domain,\n co2,\n transferSize: pageXray.domains[domain].transferSize,\n });\n }\n co2PerDomain.sort((a, b) => b.co2 - a.co2);\n\n return co2PerDomain;\n }\n\n perPage(pageXray, green) {\n // Accept an xray object, and if we receive a boolean as the second\n // argument, we assume every request we make is sent to a server\n // running on renwewable power.\n\n // if we receive an array of domains, return a number accounting the\n // reduced CO2 from green hosted domains\n\n const domainCO2 = this.perDomain(pageXray, green);\n let totalCO2 = 0;\n for (let domain of domainCO2) {\n totalCO2 += domain.co2;\n }\n return totalCO2;\n }\n\n perContentType(pageXray, greenDomains) {\n const co2PerContentType = {};\n for (let asset of pageXray.assets) {\n const domain = new URL(asset.url).domain;\n const transferSize = asset.transferSize;\n const co2ForTransfer = this.perByte(\n transferSize,\n greenDomains && greenDomains.indexOf(domain) > -1\n );\n const contentType = asset.type;\n if (!co2PerContentType[contentType]) {\n co2PerContentType[contentType] = { co2: 0, transferSize: 0 };\n }\n co2PerContentType[contentType].co2 += co2ForTransfer;\n co2PerContentType[contentType].transferSize += transferSize;\n }\n // restructure and sort\n const all = [];\n for (let type of Object.keys(co2PerContentType)) {\n all.push({\n type,\n co2: co2PerContentType[type].co2,\n transferSize: co2PerContentType[type].transferSize,\n });\n }\n all.sort((a, b) => b.co2 - a.co2);\n return all;\n }\n\n dirtiestResources(pageXray, greenDomains) {\n const allAssets = [];\n for (let asset of pageXray.assets) {\n const domain = new URL(asset.url).domain;\n const transferSize = asset.transferSize;\n const co2ForTransfer = this.perByte(\n transferSize,\n greenDomains && greenDomains.indexOf(domain) > -1\n );\n allAssets.push({ url: asset.url, co2: co2ForTransfer, transferSize });\n }\n allAssets.sort((a, b) => b.co2 - a.co2);\n\n return allAssets.slice(0, allAssets.length > 10 ? 10 : allAssets.length);\n }\n\n perParty(pageXray, greenDomains) {\n let firstParty = 0;\n let thirdParty = 0;\n // calculate co2 per first/third party\n const firstPartyRegEx = pageXray.firstPartyRegEx;\n for (let d of Object.keys(pageXray.domains)) {\n if (!d.match(firstPartyRegEx)) {\n thirdParty += this.perByte(\n pageXray.domains[d].transferSize,\n greenDomains && greenDomains.indexOf(d) > -1\n );\n } else {\n firstParty += this.perByte(\n pageXray.domains[d].transferSize,\n greenDomains && greenDomains.indexOf(d) > -1\n );\n }\n }\n return { firstParty, thirdParty };\n }\n}\n\nexport { CO2 };\nexport default CO2;\n"],
4
+ "sourcesContent": ["\"use strict\";\n\n/**\n * @typedef {Object} CO2EstimateTraceResultPerByte\n * @property {number} co2 - The CO2 estimate in grams/kilowatt-hour\n * @property {boolean} green - Whether the domain is green or not\n * @property {TraceResultVariables} variables - The variables used to calculate the CO2 estimate\n */\n\n/**\n * @typedef {Object} CO2EstimateTraceResultPerVisit\n * @property {number} co2 - The CO2 estimate in grams/kilowatt-hour\n * @property {boolean} green - Whether the domain is green or not\n * @property {TraceResultVariables} variables - The variables used to calculate the CO2 estimate\n */\n\n/**\n * @typedef {Object} TraceResultVariablesPerByte\n * @property {GridIntensityVariables} gridIntensity - The grid intensity related variables\n */\n/**\n * @typedef {Object} TraceResultVariablesPerVisit\n * @property {GridIntensityVariables} gridIntensity - The grid intensity related variables\n * @property {number} dataReloadRatio - What percentage of a page is reloaded on each subsequent page view\n * @property {number} firstVisitPercentage - What percentage of visits are loading this page for subsequent times\n * @property {number} returnVisitPercentage - What percentage of visits are loading this page for the second or more time\n */\n\n/**\n * @typedef {Object} GridIntensityVariables\n * @property {string} description - The description of the variables\n * @property {number} network - The network grid intensity set by the user or the default\n * @property {number} dataCenter - The data center grid intensity set by the user or the default\n * @property {number} device - The device grid intensity set by the user or the default\n * @property {number} production - The production grid intensity set by the user or the default\n */\n\nimport OneByte from \"./1byte.js\";\nimport SustainableWebDesign from \"./sustainable-web-design.js\";\n\nimport {\n GLOBAL_GRID_INTENSITY,\n RENEWABLES_GRID_INTENSITY,\n} from \"./constants/index.js\";\nimport { parseOptions } from \"./helpers/index.js\";\n\nclass CO2 {\n constructor(options) {\n this.model = new SustainableWebDesign();\n // Using optional chaining allows an empty object to be passed\n // in without breaking the code.\n if (options?.model === \"1byte\") {\n this.model = new OneByte();\n } else if (options?.model === \"swd\") {\n this.model = new SustainableWebDesign();\n } else if (options?.model) {\n throw new Error(\n `\"${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.`\n );\n }\n\n /** @private */\n this._segment = options?.results === \"segment\";\n }\n\n /**\n * Accept a figure in bytes for data transfer, and a boolean for whether\n * the domain shows as 'green', and return a CO2 figure for energy used to shift the corresponding\n * the data transfer.\n *\n * @param {number} bytes\n * @param {boolean} green\n * @return {number} the amount of CO2 in grammes\n */\n perByte(bytes, green = false) {\n return this.model.perByte(bytes, green, this._segment);\n }\n\n /**\n * Accept a figure in bytes for data transfer, and a boolean for whether\n * the domain shows as 'green', and return a CO2 figure for energy used to shift the corresponding\n * the data transfer.\n *\n * @param {number} bytes\n * @param {boolean} green\n * @return {number} the amount of CO2 in grammes\n */\n perVisit(bytes, green = false) {\n if (this.model?.perVisit) {\n return this.model.perVisit(bytes, green, this._segment);\n } else {\n throw new Error(\n `The perVisit() method is not supported in the model you are using. Try using perByte() instead.\\nSee https://developers.thegreenwebfoundation.org/co2js/methods/ to learn more about the methods available in CO2.js.`\n );\n }\n }\n\n /**\n * Accept a figure in bytes for data transfer, a boolean for whether\n * the domain shows as 'green', and an options object.\n * Returns an object containing CO2 figure, green boolean, and object of the variables used in calculating the CO2 figure.\n *\n * @param {number} bytes\n * @param {boolean} green\n * @param {Object} options\n * @return {CO2EstimateTraceResultPerByte} the amount of CO2 in grammes\n */\n perByteTrace(bytes, green = false, options = {}) {\n let adjustments = {};\n if (options) {\n // If there are options, parse them and add them to the model.\n adjustments = parseOptions(options);\n }\n return {\n co2: this.model.perByte(bytes, green, this._segment, adjustments),\n green,\n variables: {\n description:\n \"Below are the variables used to calculate this CO2 estimate.\",\n bytes,\n gridIntensity: {\n description:\n \"The grid intensity (grams per kilowatt-hour) used to calculate this CO2 estimate.\",\n network:\n adjustments?.gridIntensity?.network?.value ?? GLOBAL_GRID_INTENSITY,\n dataCenter: green\n ? RENEWABLES_GRID_INTENSITY\n : adjustments?.gridIntensity?.dataCenter?.value ??\n GLOBAL_GRID_INTENSITY,\n production: GLOBAL_GRID_INTENSITY,\n device:\n adjustments?.gridIntensity?.device?.value ?? GLOBAL_GRID_INTENSITY,\n },\n },\n };\n }\n\n /**\n * Accept a figure in bytes for data transfer, a boolean for whether\n * the domain shows as 'green', and an options object.\n * Returns an object containing CO2 figure, green boolean, and object of the variables used in calculating the CO2 figure.\n *\n * @param {number} bytes\n * @param {boolean} green\n * @param {Object} options\n * @return {CO2EstimateTraceResultPerVisit} the amount of CO2 in grammes\n */\n perVisitTrace(bytes, green = false, options = {}) {\n if (this.model?.perVisit) {\n let adjustments = {};\n if (options) {\n // If there are options, parse them and add them to the model.\n adjustments = parseOptions(options);\n }\n\n return {\n co2: this.model.perVisit(bytes, green, this._segment, adjustments),\n green,\n variables: {\n description:\n \"Below are the variables used to calculate this CO2 estimate.\",\n bytes,\n gridIntensity: {\n description:\n \"The grid intensity (grams per kilowatt-hour) used to calculate this CO2 estimate.\",\n network:\n adjustments?.gridIntensity?.network?.value ??\n GLOBAL_GRID_INTENSITY,\n dataCenter: green\n ? RENEWABLES_GRID_INTENSITY\n : adjustments?.gridIntensity?.dataCenter?.value ??\n GLOBAL_GRID_INTENSITY,\n production: GLOBAL_GRID_INTENSITY,\n device:\n adjustments?.gridIntensity?.device?.value ??\n GLOBAL_GRID_INTENSITY,\n },\n dataReloadRatio: adjustments?.dataReloadRatio ?? 0.02,\n firstVisitPercentage: adjustments?.firstVisitPercentage ?? 0.75,\n returnVisitPercentage: adjustments?.returnVisitPercentage ?? 0.25,\n },\n };\n } else {\n throw new Error(\n `The perVisitDetailed() method is not supported in the model you are using. Try using perByte() instead.\\nSee https://developers.thegreenwebfoundation.org/co2js/methods/ to learn more about the methods available in CO2.js.`\n );\n }\n }\n\n perDomain(pageXray, greenDomains) {\n const co2PerDomain = [];\n for (let domain of Object.keys(pageXray.domains)) {\n let co2;\n if (greenDomains && greenDomains.indexOf(domain) > -1) {\n co2 = this.perByte(pageXray.domains[domain].transferSize, true);\n } else {\n co2 = this.perByte(pageXray.domains[domain].transferSize);\n }\n co2PerDomain.push({\n domain,\n co2,\n transferSize: pageXray.domains[domain].transferSize,\n });\n }\n co2PerDomain.sort((a, b) => b.co2 - a.co2);\n\n return co2PerDomain;\n }\n\n perPage(pageXray, green) {\n // Accept an xray object, and if we receive a boolean as the second\n // argument, we assume every request we make is sent to a server\n // running on renwewable power.\n\n // if we receive an array of domains, return a number accounting the\n // reduced CO2 from green hosted domains\n\n const domainCO2 = this.perDomain(pageXray, green);\n let totalCO2 = 0;\n for (let domain of domainCO2) {\n totalCO2 += domain.co2;\n }\n return totalCO2;\n }\n\n perContentType(pageXray, greenDomains) {\n const co2PerContentType = {};\n for (let asset of pageXray.assets) {\n const domain = new URL(asset.url).domain;\n const transferSize = asset.transferSize;\n const co2ForTransfer = this.perByte(\n transferSize,\n greenDomains && greenDomains.indexOf(domain) > -1\n );\n const contentType = asset.type;\n if (!co2PerContentType[contentType]) {\n co2PerContentType[contentType] = { co2: 0, transferSize: 0 };\n }\n co2PerContentType[contentType].co2 += co2ForTransfer;\n co2PerContentType[contentType].transferSize += transferSize;\n }\n // restructure and sort\n const all = [];\n for (let type of Object.keys(co2PerContentType)) {\n all.push({\n type,\n co2: co2PerContentType[type].co2,\n transferSize: co2PerContentType[type].transferSize,\n });\n }\n all.sort((a, b) => b.co2 - a.co2);\n return all;\n }\n\n dirtiestResources(pageXray, greenDomains) {\n const allAssets = [];\n for (let asset of pageXray.assets) {\n const domain = new URL(asset.url).domain;\n const transferSize = asset.transferSize;\n const co2ForTransfer = this.perByte(\n transferSize,\n greenDomains && greenDomains.indexOf(domain) > -1\n );\n allAssets.push({ url: asset.url, co2: co2ForTransfer, transferSize });\n }\n allAssets.sort((a, b) => b.co2 - a.co2);\n\n return allAssets.slice(0, allAssets.length > 10 ? 10 : allAssets.length);\n }\n\n perParty(pageXray, greenDomains) {\n let firstParty = 0;\n let thirdParty = 0;\n // calculate co2 per first/third party\n const firstPartyRegEx = pageXray.firstPartyRegEx;\n for (let d of Object.keys(pageXray.domains)) {\n if (!d.match(firstPartyRegEx)) {\n thirdParty += this.perByte(\n pageXray.domains[d].transferSize,\n greenDomains && greenDomains.indexOf(d) > -1\n );\n } else {\n firstParty += this.perByte(\n pageXray.domains[d].transferSize,\n greenDomains && greenDomains.indexOf(d) > -1\n );\n }\n }\n return { firstParty, thirdParty };\n }\n}\n\nexport { CO2 };\nexport default CO2;\n"],
5
5
  "mappings": ";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAqCA,kBAAoB;AACpB,oCAAiC;AAEjC,uBAGO;AACP,qBAA6B;AAE7B,MAAM,IAAI;AAAA,EACR,YAAY,SAAS;AACnB,SAAK,QAAQ,IAAI,sCAAqB;AAGtC,QAAI,oCAAS,WAAU,SAAS;AAC9B,WAAK,QAAQ,IAAI,oBAAQ;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;AAAA,EAEA,SAAS,UAAU,cAAc;AAC/B,QAAI,aAAa;AACjB,QAAI,aAAa;AAEjB,UAAM,kBAAkB,SAAS;AACjC,aAAS,KAAK,OAAO,KAAK,SAAS,OAAO,GAAG;AAC3C,UAAI,CAAC,EAAE,MAAM,eAAe,GAAG;AAC7B,sBAAc,KAAK,QACjB,SAAS,QAAQ,GAAG,cACpB,gBAAgB,aAAa,QAAQ,CAAC,IAAI,EAC5C;AAAA,MACF,OAAO;AACL,sBAAc,KAAK,QACjB,SAAS,QAAQ,GAAG,cACpB,gBAAgB,aAAa,QAAQ,CAAC,IAAI,EAC5C;AAAA,MACF;AAAA,IACF;AACA,WAAO,EAAE,YAAY,WAAW;AAAA,EAClC;AACF;AAGA,IAAO,cAAQ;",
6
6
  "names": []
7
7
  }
@@ -22,7 +22,7 @@ __export(average_intensities_min_exports, {
22
22
  type: () => type
23
23
  });
24
24
  module.exports = __toCommonJS(average_intensities_min_exports);
25
- const data = { "AFG": 120.48, "AFRICA": 484.16, "ALB": 23.44, "DZA": 498.9, "ASM": 687.5, "AGO": 195.98, "ATG": 657.14, "ARG": 344.31, "ARM": 222.68, "ABW": 591.4, "ASEAN": 508.06, "ASIA": 535.23, "AUS": 501.7, "AUT": 157.52, "AZE": 532.9, "BHS": 698.11, "BHR": 494.02, "BGD": 577.03, "BRB": 644.86, "BLR": 415.64, "BEL": 165.36, "BLZ": 484.38, "BEN": 666.67, "BTN": 24.44, "BOL": 322.09, "BIH": 516.01, "BWA": 794.52, "BRA": 102.09, "BRN": 658.85, "BGR": 399.57, "BFA": 611.43, "BDI": 250, "CPV": 600, "KHM": 400.46, "CMR": 278.26, "CAN": 125.84, "CYM": 684.93, "CAF": 0, "TCD": 677.42, "CHL": 332.61, "CHN": 533.98, "COL": 168.95, "COM": 714.29, "COG": 395.52, "COD": 25.36, "COK": 400, "CRI": 37.21, "CIV": 410.75, "HRV": 246.46, "CUB": 602.23, "CYP": 589.35, "CZE": 415.35, "DNK": 180.71, "DJI": 666.67, "DMA": 529.41, "DOM": 549.8, "ECU": 188.71, "EGY": 469.63, "SLV": 194.23, "GNQ": 492.96, "ERI": 688.89, "EST": 464.03, "SWZ": 189.19, "ETH": 25.19, "EU": 277.19, "EUROPE": 296.45, "FLK": 500, "FRO": 428.57, "FJI": 289.47, "FIN": 130.98, "FRA": 84.82, "GUF": 254.72, "PYF": 471.43, "G20": 442.38, "G7": 343.92, "GAB": 397.38, "GMB": 700, "GEO": 134.83, "DEU": 384.83, "GHA": 361.2, "GRC": 343.82, "GRL": 133.33, "GRD": 714.29, "GLP": 623.53, "GUM": 670.33, "GTM": 291.55, "GIN": 208.63, "GNB": 750, "GUY": 642.28, "HTI": 606.06, "HND": 373.96, "HKG": 683.97, "HUN": 222.97, "ISL": 28.56, "IND": 633.4, "IDN": 619.02, "IRN": 487.86, "IRQ": 498.87, "IRL": 346.33, "ISR": 548.03, "ITA": 371.69, "JAM": 537.93, "JPN": 494.86, "JOR": 399.91, "KAZ": 635.57, "KEN": 100.57, "KIR": 666.67, "XKX": 768.73, "KWT": 551.74, "KGZ": 104.43, "LAO": 242.18, "LATIN AMERICA AND CARIBBEAN": 238.68, "LVA": 181.82, "LBN": 605.74, "LSO": 20, "LBR": 304.35, "LBY": 550.42, "LTU": 194.25, "LUX": 168.14, "MAC": 491.53, "MDG": 483.25, "MWI": 133.8, "MYS": 543.87, "MDV": 651.52, "MLI": 463.13, "MLT": 495, "MTQ": 698.63, "MRT": 526.6, "MUS": 611.11, "MEX": 423.81, "MIDDLE EAST": 516.02, "MDA": 677.18, "MNG": 749.66, "MNE": 399.38, "MSR": 1e3, "MAR": 610.41, "MOZ": 126.63, "MMR": 344.37, "NAM": 63.69, "NRU": 750, "NPL": 24.51, "NLD": 355.78, "NCL": 610.12, "NZL": 97.73, "NIC": 354.21, "NER": 622.22, "NGA": 368.11, "NORTH AMERICA": 336.01, "PRK": 157.79, "MKD": 529.33, "NOR": 28.82, "OCEANIA": 449.71, "OECD": 340.95, "OMN": 488.27, "PAK": 344.16, "PSE": 465.12, "PAN": 186.61, "PNG": 526.75, "PRY": 25.49, "PER": 256.51, "POL": 633.1, "PRT": 234.03, "PRI": 681.47, "QAT": 489.88, "REU": 519.03, "ROU": 264.12, "RUS": 363.68, "RWA": 294.12, "KNA": 681.82, "LCA": 685.71, "SPM": 800, "VCT": 500, "WSM": 470.59, "STP": 600, "SAU": 557.78, "SEN": 523.13, "SRB": 569.38, "SYC": 615.39, "SLE": 47.62, "SGP": 488.78, "SVK": 140.67, "SVN": 237.38, "SLB": 727.27, "SOM": 634.15, "ZAF": 708.19, "KOR": 437.6, "SSD": 684.21, "ESP": 217.37, "LKA": 463, "SDN": 264.01, "SUR": 356.44, "SWE": 45.08, "CHE": 45.62, "SYR": 541.17, "TWN": 561.02, "TJK": 83.63, "TZA": 366.75, "THA": 501.57, "PHL": 582.84, "TGO": 460.32, "TON": 625, "TTO": 491.41, "TUN": 469.43, "TUR": 413.63, "TKM": 490.19, "TCA": 703.7, "UGA": 52.27, "UKR": 187.06, "ARE": 407.98, "GBR": 261.24, "USA": 367.26, "URY": 114.89, "UZB": 505.41, "VUT": 571.43, "VEN": 212.48, "VNM": 386.49, "VGB": 714.29, "VIR": 685.71, "WORLD": 437.26, "YEM": 543.91, "ZMB": 84.7, "ZWE": 392.28 };
25
+ const data = { "AFG": 120.48, "AFRICA": 484.16, "ALB": 23.44, "DZA": 498.9, "ASM": 687.5, "AGO": 195.98, "ATG": 657.14, "ARG": 344.31, "ARM": 222.68, "ABW": 591.4, "ASEAN": 508.06, "ASIA": 535.23, "AUS": 501.7, "AUT": 157.52, "AZE": 532.9, "BHS": 698.11, "BHR": 494.02, "BGD": 577.03, "BRB": 644.86, "BLR": 415.64, "BEL": 165.36, "BLZ": 484.38, "BEN": 666.67, "BTN": 24.44, "BOL": 322.09, "BIH": 516.01, "BWA": 794.52, "BRA": 102.09, "BRN": 658.85, "BGR": 399.57, "BFA": 611.43, "BDI": 250, "CPV": 600, "KHM": 400.46, "CMR": 278.26, "CAN": 125.84, "CYM": 684.93, "CAF": 0, "TCD": 677.42, "CHL": 332.61, "CHN": 533.98, "COL": 168.95, "COM": 714.29, "COG": 395.52, "COD": 25.36, "COK": 400, "CRI": 37.21, "CIV": 410.75, "HRV": 246.46, "CUB": 602.23, "CYP": 589.35, "CZE": 415.35, "DNK": 180.71, "DJI": 666.67, "DMA": 529.41, "DOM": 549.8, "ECU": 188.71, "EGY": 469.63, "SLV": 194.23, "GNQ": 492.96, "ERI": 688.89, "EST": 464.03, "SWZ": 189.19, "ETH": 25.19, "EU": 276.5, "EUROPE": 297.16, "FLK": 500, "FRO": 428.57, "FJI": 289.47, "FIN": 130.98, "FRA": 84.82, "GUF": 254.72, "PYF": 471.43, "G20": 442.62, "G7": 344.29, "GAB": 397.38, "GMB": 700, "GEO": 134.83, "DEU": 385.38, "GHA": 361.2, "GRC": 343.82, "GRL": 133.33, "GRD": 714.29, "GLP": 623.53, "GUM": 670.33, "GTM": 291.55, "GIN": 208.63, "GNB": 750, "GUY": 642.28, "HTI": 606.06, "HND": 373.96, "HKG": 683.97, "HUN": 222.97, "ISL": 28.56, "IND": 633.4, "IDN": 619.02, "IRN": 487.86, "IRQ": 498.87, "IRL": 346.33, "ISR": 548.03, "ITA": 371.69, "JAM": 537.93, "JPN": 494.86, "JOR": 399.91, "KAZ": 635.57, "KEN": 100.57, "KIR": 666.67, "XKX": 768.73, "KWT": 551.74, "KGZ": 104.43, "LAO": 242.18, "LATIN AMERICA AND CARIBBEAN": 238.68, "LVA": 181.82, "LBN": 605.74, "LSO": 20, "LBR": 304.35, "LBY": 550.42, "LTU": 194.25, "LUX": 168.14, "MAC": 491.53, "MDG": 483.25, "MWI": 133.8, "MYS": 543.87, "MDV": 651.52, "MLI": 463.13, "MLT": 495, "MTQ": 698.63, "MRT": 526.6, "MUS": 611.11, "MEX": 423.81, "MIDDLE EAST": 516.02, "MDA": 677.18, "MNG": 749.66, "MNE": 399.38, "MSR": 1e3, "MAR": 610.41, "MOZ": 126.63, "MMR": 344.37, "NAM": 63.69, "NRU": 750, "NPL": 24.51, "NLD": 355.78, "NCL": 610.12, "NZL": 97.73, "NIC": 354.21, "NER": 622.22, "NGA": 368.11, "NORTH AMERICA": 336.68, "PRK": 157.79, "MKD": 529.33, "NOR": 28.82, "OCEANIA": 449.71, "OECD": 341.2, "OMN": 488.27, "PAK": 344.16, "PSE": 465.12, "PAN": 186.61, "PNG": 526.75, "PRY": 25.49, "PER": 256.51, "POL": 633.1, "PRT": 234.03, "PRI": 681.47, "QAT": 489.88, "REU": 519.03, "ROU": 264.12, "RUS": 363.68, "RWA": 294.12, "KNA": 681.82, "LCA": 685.71, "SPM": 800, "VCT": 500, "WSM": 470.59, "STP": 600, "SAU": 557.78, "SEN": 523.13, "SRB": 569.38, "SYC": 615.39, "SLE": 47.62, "SGP": 488.78, "SVK": 140.67, "SVN": 237.38, "SLB": 727.27, "SOM": 634.15, "ZAF": 708.21, "KOR": 437.6, "SSD": 684.21, "ESP": 217.37, "LKA": 463, "SDN": 264.01, "SUR": 356.44, "SWE": 45.08, "CHE": 45.62, "SYR": 541.17, "TWN": 560.98, "TJK": 83.63, "TZA": 366.75, "THA": 501.57, "PHL": 582.84, "TGO": 460.32, "TON": 625, "TTO": 491.41, "TUN": 469.43, "TUR": 413.63, "TKM": 490.19, "TCA": 703.7, "UGA": 52.27, "UKR": 230.89, "ARE": 407.98, "GBR": 261.24, "USA": 368.1, "URY": 114.89, "UZB": 505.41, "VUT": 571.43, "VEN": 212.48, "VNM": 386.49, "VGB": 714.29, "VIR": 685.71, "WORLD": 437.67, "YEM": 543.91, "ZMB": 84.7, "ZWE": 392.28 };
26
26
  const type = "average";
27
27
  var average_intensities_min_default = { data, type };
28
28
  //# sourceMappingURL=average-intensities.min.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/data/average-intensities.min.js"],
4
- "sourcesContent": ["const data = {\"AFG\":120.48,\"AFRICA\":484.16,\"ALB\":23.44,\"DZA\":498.9,\"ASM\":687.5,\"AGO\":195.98,\"ATG\":657.14,\"ARG\":344.31,\"ARM\":222.68,\"ABW\":591.4,\"ASEAN\":508.06,\"ASIA\":535.23,\"AUS\":501.7,\"AUT\":157.52,\"AZE\":532.9,\"BHS\":698.11,\"BHR\":494.02,\"BGD\":577.03,\"BRB\":644.86,\"BLR\":415.64,\"BEL\":165.36,\"BLZ\":484.38,\"BEN\":666.67,\"BTN\":24.44,\"BOL\":322.09,\"BIH\":516.01,\"BWA\":794.52,\"BRA\":102.09,\"BRN\":658.85,\"BGR\":399.57,\"BFA\":611.43,\"BDI\":250,\"CPV\":600,\"KHM\":400.46,\"CMR\":278.26,\"CAN\":125.84,\"CYM\":684.93,\"CAF\":0,\"TCD\":677.42,\"CHL\":332.61,\"CHN\":533.98,\"COL\":168.95,\"COM\":714.29,\"COG\":395.52,\"COD\":25.36,\"COK\":400,\"CRI\":37.21,\"CIV\":410.75,\"HRV\":246.46,\"CUB\":602.23,\"CYP\":589.35,\"CZE\":415.35,\"DNK\":180.71,\"DJI\":666.67,\"DMA\":529.41,\"DOM\":549.8,\"ECU\":188.71,\"EGY\":469.63,\"SLV\":194.23,\"GNQ\":492.96,\"ERI\":688.89,\"EST\":464.03,\"SWZ\":189.19,\"ETH\":25.19,\"EU\":277.19,\"EUROPE\":296.45,\"FLK\":500,\"FRO\":428.57,\"FJI\":289.47,\"FIN\":130.98,\"FRA\":84.82,\"GUF\":254.72,\"PYF\":471.43,\"G20\":442.38,\"G7\":343.92,\"GAB\":397.38,\"GMB\":700,\"GEO\":134.83,\"DEU\":384.83,\"GHA\":361.2,\"GRC\":343.82,\"GRL\":133.33,\"GRD\":714.29,\"GLP\":623.53,\"GUM\":670.33,\"GTM\":291.55,\"GIN\":208.63,\"GNB\":750,\"GUY\":642.28,\"HTI\":606.06,\"HND\":373.96,\"HKG\":683.97,\"HUN\":222.97,\"ISL\":28.56,\"IND\":633.4,\"IDN\":619.02,\"IRN\":487.86,\"IRQ\":498.87,\"IRL\":346.33,\"ISR\":548.03,\"ITA\":371.69,\"JAM\":537.93,\"JPN\":494.86,\"JOR\":399.91,\"KAZ\":635.57,\"KEN\":100.57,\"KIR\":666.67,\"XKX\":768.73,\"KWT\":551.74,\"KGZ\":104.43,\"LAO\":242.18,\"LATIN AMERICA AND CARIBBEAN\":238.68,\"LVA\":181.82,\"LBN\":605.74,\"LSO\":20,\"LBR\":304.35,\"LBY\":550.42,\"LTU\":194.25,\"LUX\":168.14,\"MAC\":491.53,\"MDG\":483.25,\"MWI\":133.8,\"MYS\":543.87,\"MDV\":651.52,\"MLI\":463.13,\"MLT\":495,\"MTQ\":698.63,\"MRT\":526.6,\"MUS\":611.11,\"MEX\":423.81,\"MIDDLE EAST\":516.02,\"MDA\":677.18,\"MNG\":749.66,\"MNE\":399.38,\"MSR\":1000,\"MAR\":610.41,\"MOZ\":126.63,\"MMR\":344.37,\"NAM\":63.69,\"NRU\":750,\"NPL\":24.51,\"NLD\":355.78,\"NCL\":610.12,\"NZL\":97.73,\"NIC\":354.21,\"NER\":622.22,\"NGA\":368.11,\"NORTH AMERICA\":336.01,\"PRK\":157.79,\"MKD\":529.33,\"NOR\":28.82,\"OCEANIA\":449.71,\"OECD\":340.95,\"OMN\":488.27,\"PAK\":344.16,\"PSE\":465.12,\"PAN\":186.61,\"PNG\":526.75,\"PRY\":25.49,\"PER\":256.51,\"POL\":633.1,\"PRT\":234.03,\"PRI\":681.47,\"QAT\":489.88,\"REU\":519.03,\"ROU\":264.12,\"RUS\":363.68,\"RWA\":294.12,\"KNA\":681.82,\"LCA\":685.71,\"SPM\":800,\"VCT\":500,\"WSM\":470.59,\"STP\":600,\"SAU\":557.78,\"SEN\":523.13,\"SRB\":569.38,\"SYC\":615.39,\"SLE\":47.62,\"SGP\":488.78,\"SVK\":140.67,\"SVN\":237.38,\"SLB\":727.27,\"SOM\":634.15,\"ZAF\":708.19,\"KOR\":437.6,\"SSD\":684.21,\"ESP\":217.37,\"LKA\":463,\"SDN\":264.01,\"SUR\":356.44,\"SWE\":45.08,\"CHE\":45.62,\"SYR\":541.17,\"TWN\":561.02,\"TJK\":83.63,\"TZA\":366.75,\"THA\":501.57,\"PHL\":582.84,\"TGO\":460.32,\"TON\":625,\"TTO\":491.41,\"TUN\":469.43,\"TUR\":413.63,\"TKM\":490.19,\"TCA\":703.7,\"UGA\":52.27,\"UKR\":187.06,\"ARE\":407.98,\"GBR\":261.24,\"USA\":367.26,\"URY\":114.89,\"UZB\":505.41,\"VUT\":571.43,\"VEN\":212.48,\"VNM\":386.49,\"VGB\":714.29,\"VIR\":685.71,\"WORLD\":437.26,\"YEM\":543.91,\"ZMB\":84.7,\"ZWE\":392.28}; const type = \"average\"; export { data, type }; export default { data, type };"],
5
- "mappings": ";;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,MAAM,OAAO,EAAC,OAAM,QAAO,UAAS,QAAO,OAAM,OAAM,OAAM,OAAM,OAAM,OAAM,OAAM,QAAO,OAAM,QAAO,OAAM,QAAO,OAAM,QAAO,OAAM,OAAM,SAAQ,QAAO,QAAO,QAAO,OAAM,OAAM,OAAM,QAAO,OAAM,OAAM,OAAM,QAAO,OAAM,QAAO,OAAM,QAAO,OAAM,QAAO,OAAM,QAAO,OAAM,QAAO,OAAM,QAAO,OAAM,QAAO,OAAM,OAAM,OAAM,QAAO,OAAM,QAAO,OAAM,QAAO,OAAM,QAAO,OAAM,QAAO,OAAM,QAAO,OAAM,QAAO,OAAM,KAAI,OAAM,KAAI,OAAM,QAAO,OAAM,QAAO,OAAM,QAAO,OAAM,QAAO,OAAM,GAAE,OAAM,QAAO,OAAM,QAAO,OAAM,QAAO,OAAM,QAAO,OAAM,QAAO,OAAM,QAAO,OAAM,OAAM,OAAM,KAAI,OAAM,OAAM,OAAM,QAAO,OAAM,QAAO,OAAM,QAAO,OAAM,QAAO,OAAM,QAAO,OAAM,QAAO,OAAM,QAAO,OAAM,Q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AAO,OAAM,QAAO,OAAM,OAAM,OAAM,QAAO,OAAM,OAAM,OAAM,QAAO,OAAM,QAAO,OAAM,QAAO,OAAM,QAAO,OAAM,QAAO,OAAM,QAAO,OAAM,QAAO,OAAM,QAAO,OAAM,QAAO,OAAM,KAAI,OAAM,KAAI,OAAM,QAAO,OAAM,KAAI,OAAM,QAAO,OAAM,QAAO,OAAM,QAAO,OAAM,QAAO,OAAM,OAAM,OAAM,QAAO,OAAM,QAAO,OAAM,QAAO,OAAM,QAAO,OAAM,QAAO,OAAM,QAAO,OAAM,OAAM,OAAM,QAAO,OAAM,QAAO,OAAM,KAAI,OAAM,QAAO,OAAM,QAAO,OAAM,OAAM,OAAM,OAAM,OAAM,QAAO,OAAM,QAAO,OAAM,OAAM,OAAM,QAAO,OAAM,QAAO,OAAM,QAAO,OAAM,QAAO,OAAM,KAAI,OAAM,QAAO,OAAM,QAAO,OAAM,QAAO,OAAM,QAAO,OAAM,OAAM,OAAM,OAAM,OAAM,QAAO,OAAM,QAAO,OAAM,QAAO,OAAM,QAAO,OAAM,QAAO,OAAM,QAAO,OAAM,QAAO,OAAM,QAAO,OAAM,QAAO,OAAM,QAAO,OAAM,QAAO,SAAQ,QAAO,OAAM,QAAO,OAAM,MAAK,OAAM,OAAM;AAAG,MAAM,OAAO;AAAkC,IAAO,kCAAQ,EAAE,MAAM,KAAK;",
4
+ "sourcesContent": ["const data = {\"AFG\":120.48,\"AFRICA\":484.16,\"ALB\":23.44,\"DZA\":498.9,\"ASM\":687.5,\"AGO\":195.98,\"ATG\":657.14,\"ARG\":344.31,\"ARM\":222.68,\"ABW\":591.4,\"ASEAN\":508.06,\"ASIA\":535.23,\"AUS\":501.7,\"AUT\":157.52,\"AZE\":532.9,\"BHS\":698.11,\"BHR\":494.02,\"BGD\":577.03,\"BRB\":644.86,\"BLR\":415.64,\"BEL\":165.36,\"BLZ\":484.38,\"BEN\":666.67,\"BTN\":24.44,\"BOL\":322.09,\"BIH\":516.01,\"BWA\":794.52,\"BRA\":102.09,\"BRN\":658.85,\"BGR\":399.57,\"BFA\":611.43,\"BDI\":250,\"CPV\":600,\"KHM\":400.46,\"CMR\":278.26,\"CAN\":125.84,\"CYM\":684.93,\"CAF\":0,\"TCD\":677.42,\"CHL\":332.61,\"CHN\":533.98,\"COL\":168.95,\"COM\":714.29,\"COG\":395.52,\"COD\":25.36,\"COK\":400,\"CRI\":37.21,\"CIV\":410.75,\"HRV\":246.46,\"CUB\":602.23,\"CYP\":589.35,\"CZE\":415.35,\"DNK\":180.71,\"DJI\":666.67,\"DMA\":529.41,\"DOM\":549.8,\"ECU\":188.71,\"EGY\":469.63,\"SLV\":194.23,\"GNQ\":492.96,\"ERI\":688.89,\"EST\":464.03,\"SWZ\":189.19,\"ETH\":25.19,\"EU\":276.5,\"EUROPE\":297.16,\"FLK\":500,\"FRO\":428.57,\"FJI\":289.47,\"FIN\":130.98,\"FRA\":84.82,\"GUF\":254.72,\"PYF\":471.43,\"G20\":442.62,\"G7\":344.29,\"GAB\":397.38,\"GMB\":700,\"GEO\":134.83,\"DEU\":385.38,\"GHA\":361.2,\"GRC\":343.82,\"GRL\":133.33,\"GRD\":714.29,\"GLP\":623.53,\"GUM\":670.33,\"GTM\":291.55,\"GIN\":208.63,\"GNB\":750,\"GUY\":642.28,\"HTI\":606.06,\"HND\":373.96,\"HKG\":683.97,\"HUN\":222.97,\"ISL\":28.56,\"IND\":633.4,\"IDN\":619.02,\"IRN\":487.86,\"IRQ\":498.87,\"IRL\":346.33,\"ISR\":548.03,\"ITA\":371.69,\"JAM\":537.93,\"JPN\":494.86,\"JOR\":399.91,\"KAZ\":635.57,\"KEN\":100.57,\"KIR\":666.67,\"XKX\":768.73,\"KWT\":551.74,\"KGZ\":104.43,\"LAO\":242.18,\"LATIN AMERICA AND CARIBBEAN\":238.68,\"LVA\":181.82,\"LBN\":605.74,\"LSO\":20,\"LBR\":304.35,\"LBY\":550.42,\"LTU\":194.25,\"LUX\":168.14,\"MAC\":491.53,\"MDG\":483.25,\"MWI\":133.8,\"MYS\":543.87,\"MDV\":651.52,\"MLI\":463.13,\"MLT\":495,\"MTQ\":698.63,\"MRT\":526.6,\"MUS\":611.11,\"MEX\":423.81,\"MIDDLE EAST\":516.02,\"MDA\":677.18,\"MNG\":749.66,\"MNE\":399.38,\"MSR\":1000,\"MAR\":610.41,\"MOZ\":126.63,\"MMR\":344.37,\"NAM\":63.69,\"NRU\":750,\"NPL\":24.51,\"NLD\":355.78,\"NCL\":610.12,\"NZL\":97.73,\"NIC\":354.21,\"NER\":622.22,\"NGA\":368.11,\"NORTH AMERICA\":336.68,\"PRK\":157.79,\"MKD\":529.33,\"NOR\":28.82,\"OCEANIA\":449.71,\"OECD\":341.2,\"OMN\":488.27,\"PAK\":344.16,\"PSE\":465.12,\"PAN\":186.61,\"PNG\":526.75,\"PRY\":25.49,\"PER\":256.51,\"POL\":633.1,\"PRT\":234.03,\"PRI\":681.47,\"QAT\":489.88,\"REU\":519.03,\"ROU\":264.12,\"RUS\":363.68,\"RWA\":294.12,\"KNA\":681.82,\"LCA\":685.71,\"SPM\":800,\"VCT\":500,\"WSM\":470.59,\"STP\":600,\"SAU\":557.78,\"SEN\":523.13,\"SRB\":569.38,\"SYC\":615.39,\"SLE\":47.62,\"SGP\":488.78,\"SVK\":140.67,\"SVN\":237.38,\"SLB\":727.27,\"SOM\":634.15,\"ZAF\":708.21,\"KOR\":437.6,\"SSD\":684.21,\"ESP\":217.37,\"LKA\":463,\"SDN\":264.01,\"SUR\":356.44,\"SWE\":45.08,\"CHE\":45.62,\"SYR\":541.17,\"TWN\":560.98,\"TJK\":83.63,\"TZA\":366.75,\"THA\":501.57,\"PHL\":582.84,\"TGO\":460.32,\"TON\":625,\"TTO\":491.41,\"TUN\":469.43,\"TUR\":413.63,\"TKM\":490.19,\"TCA\":703.7,\"UGA\":52.27,\"UKR\":230.89,\"ARE\":407.98,\"GBR\":261.24,\"USA\":368.1,\"URY\":114.89,\"UZB\":505.41,\"VUT\":571.43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AM,QAAO,OAAM,OAAM,OAAM,QAAO,OAAM,QAAO,OAAM,KAAI,OAAM,QAAO,OAAM,QAAO,OAAM,OAAM,OAAM,OAAM,OAAM,QAAO,OAAM,QAAO,OAAM,OAAM,OAAM,QAAO,OAAM,QAAO,OAAM,QAAO,OAAM,QAAO,OAAM,KAAI,OAAM,QAAO,OAAM,QAAO,OAAM,QAAO,OAAM,QAAO,OAAM,OAAM,OAAM,OAAM,OAAM,QAAO,OAAM,QAAO,OAAM,QAAO,OAAM,OAAM,OAAM,QAAO,OAAM,QAAO,OAAM,QAAO,OAAM,QAAO,OAAM,QAAO,OAAM,QAAO,OAAM,QAAO,SAAQ,QAAO,OAAM,QAAO,OAAM,MAAK,OAAM,OAAM;AAAG,MAAM,OAAO;AAAkC,IAAO,kCAAQ,EAAE,MAAM,KAAK;",
6
6
  "names": []
7
7
  }
@@ -33,7 +33,7 @@ function parseOptions(options) {
33
33
  if (options == null ? void 0 : options.gridIntensity) {
34
34
  adjustments.gridIntensity = {};
35
35
  const { device, dataCenter, network } = options.gridIntensity;
36
- if (device) {
36
+ if (device || device === 0) {
37
37
  if (typeof device === "object") {
38
38
  if (!import__.averageIntensity.data[(_a = device.country) == null ? void 0 : _a.toUpperCase()]) {
39
39
  console.warn(`"${device.country}" is not a valid country. Please use a valid 3 digit ISO 3166 country code.
@@ -59,7 +59,7 @@ Falling back to global average grid intensity.`);
59
59
  Falling back to global average grid intensity.`);
60
60
  }
61
61
  }
62
- if (dataCenter) {
62
+ if (dataCenter || dataCenter === 0) {
63
63
  if (typeof dataCenter === "object") {
64
64
  if (!import__.averageIntensity.data[(_c = dataCenter.country) == null ? void 0 : _c.toUpperCase()]) {
65
65
  console.warn(`"${dataCenter.country}" is not a valid country. Please use a valid 3 digit ISO 3166 country code.
@@ -85,7 +85,7 @@ Falling back to global average grid intensity.`);
85
85
  Falling back to global average grid intensity.`);
86
86
  }
87
87
  }
88
- if (network) {
88
+ if (network || network === 0) {
89
89
  if (typeof network === "object") {
90
90
  if (!import__.averageIntensity.data[(_e = network.country) == null ? void 0 : _e.toUpperCase()]) {
91
91
  console.warn(`"${network.country}" is not a valid country. Please use a valid 3 digit ISO 3166 country code.
@@ -112,7 +112,7 @@ Falling back to global average grid intensity.`);
112
112
  }
113
113
  }
114
114
  }
115
- if (options == null ? void 0 : options.dataReloadRatio) {
115
+ if ((options == null ? void 0 : options.dataReloadRatio) || options.dataReloadRatio === 0) {
116
116
  if (typeof options.dataReloadRatio === "number") {
117
117
  if (options.dataReloadRatio >= 0 && options.dataReloadRatio <= 1) {
118
118
  adjustments.dataReloadRatio = options.dataReloadRatio;
@@ -127,7 +127,7 @@ Falling back to default value.`);
127
127
  Falling back to default value.`);
128
128
  }
129
129
  }
130
- if (options == null ? void 0 : options.firstVisitPercentage) {
130
+ if ((options == null ? void 0 : options.firstVisitPercentage) || options.firstVisitPercentage === 0) {
131
131
  if (typeof options.firstVisitPercentage === "number") {
132
132
  if (options.firstVisitPercentage >= 0 && options.firstVisitPercentage <= 1) {
133
133
  adjustments.firstVisitPercentage = options.firstVisitPercentage;
@@ -142,7 +142,7 @@ Falling back to default value.`);
142
142
  Falling back to default value.`);
143
143
  }
144
144
  }
145
- if (options == null ? void 0 : options.returnVisitPercentage) {
145
+ if ((options == null ? void 0 : options.returnVisitPercentage) || options.returnVisitPercentage === 0) {
146
146
  if (typeof options.returnVisitPercentage === "number") {
147
147
  if (options.returnVisitPercentage >= 0 && options.returnVisitPercentage <= 1) {
148
148
  adjustments.returnVisitPercentage = options.returnVisitPercentage;
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/helpers/index.js"],
4
- "sourcesContent": ["import { averageIntensity } from \"../index.js\";\nimport {\n GLOBAL_GRID_INTENSITY,\n PERCENTAGE_OF_DATA_LOADED_ON_SUBSEQUENT_LOAD,\n FIRST_TIME_VIEWING_PERCENTAGE,\n RETURNING_VISITOR_PERCENTAGE,\n} from \"../constants/index.js\";\nconst formatNumber = (num) => parseFloat(num.toFixed(2));\n\nfunction parseOptions(options) {\n // CHeck that it is an object\n if (typeof options !== \"object\") {\n throw new Error(\"Options must be an object\");\n }\n\n const adjustments = {};\n\n if (options?.gridIntensity) {\n adjustments.gridIntensity = {};\n const { device, dataCenter, network } = options.gridIntensity;\n if (device) {\n if (typeof device === \"object\") {\n if (!averageIntensity.data[device.country?.toUpperCase()]) {\n console.warn(\n `\"${device.country}\" is not a valid country. Please use a valid 3 digit ISO 3166 country code. \\nSee https://developers.thegreenwebfoundation.org/co2js/data/ for more information. \\nFalling back to global average grid intensity.`\n );\n adjustments.gridIntensity[\"device\"] = {\n value: GLOBAL_GRID_INTENSITY,\n };\n }\n adjustments.gridIntensity[\"device\"] = {\n country: device.country,\n value: parseFloat(\n averageIntensity.data[device.country?.toUpperCase()]\n ),\n };\n } else if (typeof device === \"number\") {\n adjustments.gridIntensity[\"device\"] = {\n value: device,\n };\n } else {\n adjustments.gridIntensity[\"device\"] = {\n value: GLOBAL_GRID_INTENSITY,\n };\n console.warn(\n `The device grid intensity must be a number or an object. You passed in a ${typeof device}. \\nFalling back to global average grid intensity.`\n );\n }\n }\n if (dataCenter) {\n if (typeof dataCenter === \"object\") {\n if (!averageIntensity.data[dataCenter.country?.toUpperCase()]) {\n console.warn(\n `\"${dataCenter.country}\" is not a valid country. Please use a valid 3 digit ISO 3166 country code. \\nSee https://developers.thegreenwebfoundation.org/co2js/data/ for more information. \\nFalling back to global average grid intensity.`\n );\n adjustments.gridIntensity[\"dataCenter\"] = {\n value: GLOBAL_GRID_INTENSITY,\n };\n }\n adjustments.gridIntensity[\"dataCenter\"] = {\n country: dataCenter.country,\n value: parseFloat(\n averageIntensity.data[dataCenter.country?.toUpperCase()]\n ),\n };\n } else if (typeof dataCenter === \"number\") {\n adjustments.gridIntensity[\"dataCenter\"] = {\n value: dataCenter,\n };\n } else {\n adjustments.gridIntensity[\"dataCenter\"] = {\n value: GLOBAL_GRID_INTENSITY,\n };\n console.warn(\n `The data center grid intensity must be a number or an object. You passed in a ${typeof dataCenter}. \\nFalling back to global average grid intensity.`\n );\n }\n }\n if (network) {\n if (typeof network === \"object\") {\n if (!averageIntensity.data[network.country?.toUpperCase()]) {\n console.warn(\n `\"${network.country}\" is not a valid country. Please use a valid 3 digit ISO 3166 country code. \\nSee https://developers.thegreenwebfoundation.org/co2js/data/ for more information. Falling back to global average grid intensity. \\nFalling back to global average grid intensity.`\n );\n adjustments.gridIntensity[\"network\"] = {\n value: GLOBAL_GRID_INTENSITY,\n };\n }\n adjustments.gridIntensity[\"network\"] = {\n country: network.country,\n value: parseFloat(\n averageIntensity.data[network.country?.toUpperCase()]\n ),\n };\n } else if (typeof network === \"number\") {\n adjustments.gridIntensity[\"network\"] = {\n value: network,\n };\n } else {\n adjustments.gridIntensity[\"network\"] = {\n value: GLOBAL_GRID_INTENSITY,\n };\n console.warn(\n `The network grid intensity must be a number or an object. You passed in a ${typeof network}. \\nFalling back to global average grid intensity.`\n );\n }\n }\n }\n\n if (options?.dataReloadRatio) {\n if (typeof options.dataReloadRatio === \"number\") {\n if (options.dataReloadRatio >= 0 && options.dataReloadRatio <= 1) {\n adjustments.dataReloadRatio = options.dataReloadRatio;\n } else {\n adjustments.dataReloadRatio =\n PERCENTAGE_OF_DATA_LOADED_ON_SUBSEQUENT_LOAD;\n console.warn(\n `The dataReloadRatio option must be a number between 0 and 1. You passed in ${options.dataReloadRatio}. \\nFalling back to default value.`\n );\n }\n } else {\n adjustments.dataReloadRatio =\n PERCENTAGE_OF_DATA_LOADED_ON_SUBSEQUENT_LOAD;\n console.warn(\n `The dataReloadRatio option must be a number. You passed in a ${typeof options.dataReloadRatio}. \\nFalling back to default value.`\n );\n }\n }\n\n if (options?.firstVisitPercentage) {\n if (typeof options.firstVisitPercentage === \"number\") {\n if (\n options.firstVisitPercentage >= 0 &&\n options.firstVisitPercentage <= 1\n ) {\n adjustments.firstVisitPercentage = options.firstVisitPercentage;\n } else {\n adjustments.firstVisitPercentage = FIRST_TIME_VIEWING_PERCENTAGE;\n console.warn(\n `The firstVisitPercentage option must be a number between 0 and 1. You passed in ${options.firstVisitPercentage}. \\nFalling back to default value.`\n );\n }\n } else {\n adjustments.firstVisitPercentage = FIRST_TIME_VIEWING_PERCENTAGE;\n console.warn(\n `The firstVisitPercentage option must be a number. You passed in a ${typeof options.firstVisitPercentage}. \\nFalling back to default value.`\n );\n }\n }\n\n if (options?.returnVisitPercentage) {\n if (typeof options.returnVisitPercentage === \"number\") {\n if (\n options.returnVisitPercentage >= 0 &&\n options.returnVisitPercentage <= 1\n ) {\n adjustments.returnVisitPercentage = options.returnVisitPercentage;\n } else {\n adjustments.returnVisitPercentage = RETURNING_VISITOR_PERCENTAGE;\n console.warn(\n `The returnVisitPercentage option must be a number between 0 and 1. You passed in ${options.returnVisitPercentage}. \\nFalling back to default value.`\n );\n }\n } else {\n adjustments.returnVisitPercentage = RETURNING_VISITOR_PERCENTAGE;\n console.warn(\n `The returnVisitPercentage option must be a number. You passed in a ${typeof options.returnVisitPercentage}. \\nFalling back to default value.`\n );\n }\n }\n\n return adjustments;\n}\n\nexport { formatNumber, parseOptions };\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,eAAiC;AACjC,uBAKO;AACP,MAAM,eAAe,CAAC,QAAQ,WAAW,IAAI,QAAQ,CAAC,CAAC;AAEvD,sBAAsB,SAAS;AAT/B;AAWE,MAAI,OAAO,YAAY,UAAU;AAC/B,UAAM,IAAI,MAAM,2BAA2B;AAAA,EAC7C;AAEA,QAAM,cAAc,CAAC;AAErB,MAAI,mCAAS,eAAe;AAC1B,gBAAY,gBAAgB,CAAC;AAC7B,UAAM,EAAE,QAAQ,YAAY,YAAY,QAAQ;AAChD,QAAI,QAAQ;AACV,UAAI,OAAO,WAAW,UAAU;AAC9B,YAAI,CAAC,0BAAiB,KAAK,aAAO,YAAP,mBAAgB,gBAAgB;AACzD,kBAAQ,KACN,IAAI,OAAO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QAAQ;AAAA,MAC9C,OAAO;AACL,oBAAY,wBAAwB;AACpC,gBAAQ,KACN,oFAAoF,QAAQ;AAAA,+BAC9F;AAAA,MACF;AAAA,IACF,OAAO;AACL,kBAAY,wBAAwB;AACpC,cAAQ,KACN,sEAAsE,OAAO,QAAQ;AAAA,+BACvF;AAAA,IACF;AAAA,EACF;AAEA,SAAO;AACT;",
4
+ "sourcesContent": ["import { averageIntensity } from \"../index.js\";\nimport {\n GLOBAL_GRID_INTENSITY,\n PERCENTAGE_OF_DATA_LOADED_ON_SUBSEQUENT_LOAD,\n FIRST_TIME_VIEWING_PERCENTAGE,\n RETURNING_VISITOR_PERCENTAGE,\n} from \"../constants/index.js\";\nconst formatNumber = (num) => parseFloat(num.toFixed(2));\n\nfunction parseOptions(options) {\n // CHeck that it is an object\n if (typeof options !== \"object\") {\n throw new Error(\"Options must be an object\");\n }\n\n const adjustments = {};\n\n if (options?.gridIntensity) {\n adjustments.gridIntensity = {};\n const { device, dataCenter, network } = options.gridIntensity;\n if (device || device === 0) {\n if (typeof device === \"object\") {\n if (!averageIntensity.data[device.country?.toUpperCase()]) {\n console.warn(\n `\"${device.country}\" is not a valid country. Please use a valid 3 digit ISO 3166 country code. \\nSee https://developers.thegreenwebfoundation.org/co2js/data/ for more information. \\nFalling back to global average grid intensity.`\n );\n adjustments.gridIntensity[\"device\"] = {\n value: GLOBAL_GRID_INTENSITY,\n };\n }\n adjustments.gridIntensity[\"device\"] = {\n country: device.country,\n value: parseFloat(\n averageIntensity.data[device.country?.toUpperCase()]\n ),\n };\n } else if (typeof device === \"number\") {\n adjustments.gridIntensity[\"device\"] = {\n value: device,\n };\n } else {\n adjustments.gridIntensity[\"device\"] = {\n value: GLOBAL_GRID_INTENSITY,\n };\n console.warn(\n `The device grid intensity must be a number or an object. You passed in a ${typeof device}. \\nFalling back to global average grid intensity.`\n );\n }\n }\n if (dataCenter || dataCenter === 0) {\n if (typeof dataCenter === \"object\") {\n if (!averageIntensity.data[dataCenter.country?.toUpperCase()]) {\n console.warn(\n `\"${dataCenter.country}\" is not a valid country. Please use a valid 3 digit ISO 3166 country code. \\nSee https://developers.thegreenwebfoundation.org/co2js/data/ for more information. \\nFalling back to global average grid intensity.`\n );\n adjustments.gridIntensity[\"dataCenter\"] = {\n value: GLOBAL_GRID_INTENSITY,\n };\n }\n adjustments.gridIntensity[\"dataCenter\"] = {\n country: dataCenter.country,\n value: parseFloat(\n averageIntensity.data[dataCenter.country?.toUpperCase()]\n ),\n };\n } else if (typeof dataCenter === \"number\") {\n adjustments.gridIntensity[\"dataCenter\"] = {\n value: dataCenter,\n };\n } else {\n adjustments.gridIntensity[\"dataCenter\"] = {\n value: GLOBAL_GRID_INTENSITY,\n };\n console.warn(\n `The data center grid intensity must be a number or an object. You passed in a ${typeof dataCenter}. \\nFalling back to global average grid intensity.`\n );\n }\n }\n if (network || network === 0) {\n if (typeof network === \"object\") {\n if (!averageIntensity.data[network.country?.toUpperCase()]) {\n console.warn(\n `\"${network.country}\" is not a valid country. Please use a valid 3 digit ISO 3166 country code. \\nSee https://developers.thegreenwebfoundation.org/co2js/data/ for more information. Falling back to global average grid intensity. \\nFalling back to global average grid intensity.`\n );\n adjustments.gridIntensity[\"network\"] = {\n value: GLOBAL_GRID_INTENSITY,\n };\n }\n adjustments.gridIntensity[\"network\"] = {\n country: network.country,\n value: parseFloat(\n averageIntensity.data[network.country?.toUpperCase()]\n ),\n };\n } else if (typeof network === \"number\") {\n adjustments.gridIntensity[\"network\"] = {\n value: network,\n };\n } else {\n adjustments.gridIntensity[\"network\"] = {\n value: GLOBAL_GRID_INTENSITY,\n };\n console.warn(\n `The network grid intensity must be a number or an object. You passed in a ${typeof network}. \\nFalling back to global average grid intensity.`\n );\n }\n }\n }\n\n if (options?.dataReloadRatio || options.dataReloadRatio === 0) {\n if (typeof options.dataReloadRatio === \"number\") {\n if (options.dataReloadRatio >= 0 && options.dataReloadRatio <= 1) {\n adjustments.dataReloadRatio = options.dataReloadRatio;\n } else {\n adjustments.dataReloadRatio =\n PERCENTAGE_OF_DATA_LOADED_ON_SUBSEQUENT_LOAD;\n console.warn(\n `The dataReloadRatio option must be a number between 0 and 1. You passed in ${options.dataReloadRatio}. \\nFalling back to default value.`\n );\n }\n } else {\n adjustments.dataReloadRatio =\n PERCENTAGE_OF_DATA_LOADED_ON_SUBSEQUENT_LOAD;\n console.warn(\n `The dataReloadRatio option must be a number. You passed in a ${typeof options.dataReloadRatio}. \\nFalling back to default value.`\n );\n }\n }\n\n if (options?.firstVisitPercentage || options.firstVisitPercentage === 0) {\n if (typeof options.firstVisitPercentage === \"number\") {\n if (\n options.firstVisitPercentage >= 0 &&\n options.firstVisitPercentage <= 1\n ) {\n adjustments.firstVisitPercentage = options.firstVisitPercentage;\n } else {\n adjustments.firstVisitPercentage = FIRST_TIME_VIEWING_PERCENTAGE;\n console.warn(\n `The firstVisitPercentage option must be a number between 0 and 1. You passed in ${options.firstVisitPercentage}. \\nFalling back to default value.`\n );\n }\n } else {\n adjustments.firstVisitPercentage = FIRST_TIME_VIEWING_PERCENTAGE;\n console.warn(\n `The firstVisitPercentage option must be a number. You passed in a ${typeof options.firstVisitPercentage}. \\nFalling back to default value.`\n );\n }\n }\n\n if (options?.returnVisitPercentage || options.returnVisitPercentage === 0) {\n if (typeof options.returnVisitPercentage === \"number\") {\n if (\n options.returnVisitPercentage >= 0 &&\n options.returnVisitPercentage <= 1\n ) {\n adjustments.returnVisitPercentage = options.returnVisitPercentage;\n } else {\n adjustments.returnVisitPercentage = RETURNING_VISITOR_PERCENTAGE;\n console.warn(\n `The returnVisitPercentage option must be a number between 0 and 1. You passed in ${options.returnVisitPercentage}. \\nFalling back to default value.`\n );\n }\n } else {\n adjustments.returnVisitPercentage = RETURNING_VISITOR_PERCENTAGE;\n console.warn(\n `The returnVisitPercentage option must be a number. You passed in a ${typeof options.returnVisitPercentage}. \\nFalling back to default value.`\n );\n }\n }\n\n return adjustments;\n}\n\nexport { formatNumber, parseOptions };\n"],
5
+ "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,kBACV;AACF,cAAQ,KACN,gEAAgE,OAAO,QAAQ;AAAA,+BACjF;AAAA,IACF;AAAA,EACF;AAEA,MAAI,oCAAS,yBAAwB,QAAQ,yBAAyB,GAAG;AACvE,QAAI,OAAO,QAAQ,yBAAyB,UAAU;AACpD,UACE,QAAQ,wBAAwB,KAChC,QAAQ,wBAAwB,GAChC;AACA,oBAAY,uBAAuB,QAAQ;AAAA,MAC7C,OAAO;AACL,oBAAY,uBAAuB;AACnC,gBAAQ,KACN,mFAAmF,QAAQ;AAAA,+BAC7F;AAAA,MACF;AAAA,IACF,OAAO;AACL,kBAAY,uBAAuB;AACnC,cAAQ,KACN,qEAAqE,OAAO,QAAQ;AAAA,+BACtF;AAAA,IACF;AAAA,EACF;AAEA,MAAI,oCAAS,0BAAyB,QAAQ,0BAA0B,GAAG;AACzE,QAAI,OAAO,QAAQ,0BAA0B,UAAU;AACrD,UACE,QAAQ,yBAAyB,KACjC,QAAQ,yBAAyB,GACjC;AACA,oBAAY,wBAAwB,QAAQ;AAAA,MAC9C,OAAO;AACL,oBAAY,wBAAwB;AACpC,gBAAQ,KACN,oFAAoF,QAAQ;AAAA,+BAC9F;AAAA,MACF;AAAA,IACF,OAAO;AACL,kBAAY,wBAAwB;AACpC,cAAQ,KACN,sEAAsE,OAAO,QAAQ;AAAA,+BACvF;AAAA,IACF;AAAA,EACF;AAEA,SAAO;AACT;",
6
6
  "names": []
7
7
  }
@@ -45,13 +45,13 @@ class SustainableWebDesign {
45
45
  let globalEmissions = import_constants.GLOBAL_GRID_INTENSITY;
46
46
  if (options == null ? void 0 : options.gridIntensity) {
47
47
  const { device, network, dataCenter } = options.gridIntensity;
48
- if (device == null ? void 0 : device.value) {
48
+ if ((device == null ? void 0 : device.value) || (device == null ? void 0 : device.value) === 0) {
49
49
  deviceCarbonIntensity = device.value;
50
50
  }
51
- if (network == null ? void 0 : network.value) {
51
+ if ((network == null ? void 0 : network.value) || (network == null ? void 0 : network.value) === 0) {
52
52
  networkCarbonIntensity = network.value;
53
53
  }
54
- if (dataCenter == null ? void 0 : dataCenter.value) {
54
+ if ((dataCenter == null ? void 0 : dataCenter.value) || (dataCenter == null ? void 0 : dataCenter.value) === 0) {
55
55
  dataCenterCarbonIntensity = dataCenter.value;
56
56
  }
57
57
  }
@@ -107,13 +107,13 @@ class SustainableWebDesign {
107
107
  return energyValues.reduce((prevValue, currentValue) => prevValue + currentValue);
108
108
  }
109
109
  energyPerVisitByComponent(bytes, options = {}, firstView = import_constants.FIRST_TIME_VIEWING_PERCENTAGE, returnView = import_constants.RETURNING_VISITOR_PERCENTAGE, dataReloadRatio = import_constants.PERCENTAGE_OF_DATA_LOADED_ON_SUBSEQUENT_LOAD) {
110
- if (options.dataReloadRatio) {
110
+ if (options.dataReloadRatio || options.dataReloadRatio === 0) {
111
111
  dataReloadRatio = options.dataReloadRatio;
112
112
  }
113
- if (options.firstVisitPercentage) {
113
+ if (options.firstVisitPercentage || options.firstVisitPercentage === 0) {
114
114
  firstView = options.firstVisitPercentage;
115
115
  }
116
- if (options.returnVisitPercentage) {
116
+ if (options.returnVisitPercentage || options.returnVisitPercentage === 0) {
117
117
  returnView = options.returnVisitPercentage;
118
118
  }
119
119
  const energyBycomponent = this.energyPerByteByComponent(bytes);