@tgwf/co2 0.10.3 → 0.11.0

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 (55) hide show
  1. package/.eslintignore +1 -0
  2. package/CHANGELOG.md +43 -17
  3. package/LICENSE +215 -176
  4. package/README.md +45 -2
  5. package/data/.prettierignore +7 -0
  6. package/data/IFI_Default_Grid_Factors_2021_v3.1_unfccc.csv +246 -0
  7. package/data/Lean-ICT-Materials-1byte-Model-2018.xlsx +0 -0
  8. package/data/Lean-ICT-Materials-Forecast-Model-2018.xlsx +0 -0
  9. package/data/co2-intensities-ember-2020.csv +222 -0
  10. package/data/co2-intensities-ember-2021.csv +87 -0
  11. package/data/fixtures/countries.csv +247 -0
  12. package/data/fixtures/tgwf.har +6107 -0
  13. package/data/fixtures/url2green.test.db +0 -0
  14. package/data/fixtures/url2green.test.json +1 -0
  15. package/data/fixtures/url2green.test.json.gz +0 -0
  16. package/data/functions/generate_ember_average_intensities_co2.js +75 -0
  17. package/data/functions/generate_marginal_co2.js +94 -0
  18. package/data/generate_co2_constants.py +28 -0
  19. package/data/output/average-intensities-ember-2021.js +93 -0
  20. package/data/output/average-intensities-ember-2021.json +776 -0
  21. package/data/output/marginal-intensities-unfccc-2021.js +239 -0
  22. package/data/output/marginal-intensities-unfccc-2021.json +2335 -0
  23. package/data/utils/getCountryCodes.js +32 -0
  24. package/data/utils/mapCountries.js +36 -0
  25. package/data/utils/parseCSVRow.js +29 -0
  26. package/dist/cjs/co2.js +7 -2
  27. package/dist/cjs/co2.js.map +2 -2
  28. package/dist/cjs/co2.test.js +26 -13
  29. package/dist/cjs/co2.test.js.map +2 -2
  30. package/dist/cjs/data/average-intensities-ember-2021.min.js +32 -0
  31. package/dist/cjs/data/average-intensities-ember-2021.min.js.map +7 -0
  32. package/dist/cjs/data/marginal-intensities-unfccc-2021.min.js +32 -0
  33. package/dist/cjs/data/marginal-intensities-unfccc-2021.min.js.map +7 -0
  34. package/dist/cjs/index-node.js +6 -2
  35. package/dist/cjs/index-node.js.map +2 -2
  36. package/dist/cjs/index.js +6 -2
  37. package/dist/cjs/index.js.map +2 -2
  38. package/dist/cjs/sustainable-web-design.js +0 -2
  39. package/dist/cjs/sustainable-web-design.js.map +2 -2
  40. package/dist/esm/co2.js +7 -2
  41. package/dist/esm/co2.test.js +25 -12
  42. package/dist/esm/data/average-intensities-ember-2021.min.js +12 -0
  43. package/dist/esm/data/marginal-intensities-unfccc-2021.min.js +12 -0
  44. package/dist/esm/index.js +6 -2
  45. package/dist/esm/sustainable-web-design.js +0 -2
  46. package/dist/iife/index.js +4 -0
  47. package/dist/iife/index.js.map +7 -0
  48. package/package.json +8 -2
  49. package/public/index.js +1 -1
  50. package/public/index.js.map +3 -3
  51. package/src/co2.js +12 -6
  52. package/src/data/average-intensities-ember-2021.min.js +1 -0
  53. package/src/data/marginal-intensities-unfccc-2021.min.js +1 -0
  54. package/src/index-node.js +4 -2
  55. package/src/index.js +4 -2
package/.eslintignore ADDED
@@ -0,0 +1 @@
1
+ *.min.js
package/CHANGELOG.md CHANGED
@@ -5,28 +5,55 @@ All notable changes to this project will be documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
- > **Added** for new features.
9
- > **Changed** for changes in existing functionality.
10
- > **Deprecated** for soon-to-be removed features.
11
- > **Removed** for now removed features.
12
- > **Fixed** for any bug fixes.
13
- > **Security** in case of vulnerabilities.
8
+ > - **Added** for new features.
9
+ > - **Changed** for changes in existing functionality.
10
+ > - **Deprecated** for soon-to-be removed features.
11
+ > - **Removed** for now removed features.
12
+ > - **Fixed** for any bug fixes.
13
+ > - **Security** in case of vulnerabilities.
14
14
 
15
- ## Unreleased
15
+ # Unreleased
16
+
17
+ - _(Add a summary of your feature, and if relevant the issue, in your PR for merging into `main`)_
18
+
19
+ # Released
20
+
21
+ ## [0.11.0] - 2022-10-03
22
+
23
+ ### Added
24
+
25
+ - Introduced average and marginal carbon intensity data into the library. This comes from [Ember Climate](https://ember-climate.org/data/data-explorer/) (for average carbon intensity data), and [The Green Web Foundation](https://developers.thegreenwebfoundation.org/co2js/data) (marginal intensity data, originally sourced from the UNFCCC - the United Nations Framework Convention on Climate Change). For more, [see our release guide for v0.11](https://www.thegreenwebfoundation.org/news/release-guide-co2-js-v0-11/) about the differences between the kinds of data. See [#64](https://github.com/thegreenwebfoundation/co2.js/issues/64), and [#97](https://github.com/thegreenwebfoundation/co2.js/issues/97) for more.
26
+ - Added new paths to `import` and `require` the annual, country-level average and marginal carbon intensity data mentioned above like, as javascript objects, or as JSON. See [#104 for more](https://github.com/thegreenwebfoundation/co2.js/issues/104).
27
+ - Added links to CO2.js in forms already available on CDNs to avoid needing to npm install it to try it out. See [#105 for more](https://github.com/thegreenwebfoundation/co2.js/issues/105).
28
+ - Introduced scripts to automate the generation of grid intensity data based of Ember & UNFCCC source files.
29
+ - Introduced a `release:minor` command, to automate the publishing process, to complement `release:patch`.
30
+
31
+ ### Changed
32
+
33
+ - 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).
34
+ - Updated our release commands to generate and format the carbon intensity data as part of the release process.
35
+
36
+ ## 0.10.4 2022-08-12
37
+
38
+ ### Added
39
+
40
+ - Introduced a `release:patch` command, to automate the publishing process. This is designed to make sure we always publish the most recent compiled code, by adding a rebuild step that can be easy to forget.
41
+
42
+ ## 0.10.3 2022-08-12
16
43
 
17
44
  ### Added
18
45
 
19
46
  - Introduced a new `perVisit()` function for the Sustainable Web Design model, which applies [caching and return visits assumptions](https://sustainablewebdesign.org/calculating-digital-emissions/).
20
47
 
21
- ## 0.10.2 2022-08-12
48
+ ## [0.10.2] - 2022-08-12
22
49
 
23
50
  - Added the ability to set the model used by CO2.js to the Sustainable Web Design model, using a simple 'swd' string, instead of needing to pass in a class.
24
51
 
25
- ## 0.10.1 2022-08-01
52
+ ## [0.10.1] - 2022-08-01
26
53
 
27
54
  This release used a version bump as previously we had released v0.10.0 under a pre-release tag.
28
55
 
29
- ## 0.10.0 2022-06-27
56
+ ## [0.10.0] - 2022-06-27
30
57
 
31
58
  - Added ES import syntax as the main way for handling imports and exports of code within the module.
32
59
  - Changed eslint settings to use later version of ecmascript (2020)
@@ -34,24 +61,25 @@ This release used a version bump as previously we had released v0.10.0 under a p
34
61
  - Added more consistent use of the debug logging library in files using the updated import syntax
35
62
  - Fixed the incorrect order of FIRST_TIME_VIEWING_PERCENTAGE and RETURNING_VISITOR_PERCENTAGE constants in the SWD model. This will result in **larger** values for calculations using the sustainable web design, and the default caching assumptions.
36
63
 
37
-
38
- # [0.9.0] - 2022-03-28
64
+ ## [0.9.0] - 2022-03-28
39
65
 
40
66
  ### Added
41
67
 
42
68
  - Added newly implemented Sustainable Web Design model [thanks @dryden!]
43
69
  - Added new readme page for using both emissions models
44
70
  - Added new source of data to the Sustainable Web Design model from Ember Climate.
71
+
45
72
  ### Changed
46
73
 
47
74
  - Changed the CO2 class to accept either the One Byte model or the Sustainable Web Design model
75
+
48
76
  ### Fixed
49
77
 
50
78
  - Fixed various typos.
51
79
 
52
- # [0.8.0] - 2021-11-28
80
+ ## [0.8.0] - 2021-11-28
53
81
 
54
- ### Fixed
82
+ ###  Fixed
55
83
 
56
84
  - Update further dependencies
57
85
  - Fix embarassing order of magnitude typo in 1byte model (thanks @mstaschik!)
@@ -71,7 +99,7 @@ This release used a version bump as previously we had released v0.10.0 under a p
71
99
  - Update tests to avoid network requests #50
72
100
  - Update dependencies across the board
73
101
 
74
- ### Changed
102
+ ###  Changed
75
103
 
76
104
  - Switch to github actions instead of travis for CI.
77
105
 
@@ -105,7 +133,6 @@ This release used a version bump as previously we had released v0.10.0 under a p
105
133
  - Incorporated class based CO2 models from @soulgalore
106
134
  - Credit contributors
107
135
 
108
-
109
136
  ## [0.4.7] - 2020-03-02
110
137
 
111
138
  ### Added
@@ -135,4 +162,3 @@ Update the 1byte model to use an average of devices, rather than just wifi
135
162
  ### Changed
136
163
 
137
164
  Split hosting API into two separate files (one for sqlite, and one relying on the greencheck API)
138
-
package/LICENSE CHANGED
@@ -1,176 +1,215 @@
1
- Apache License
2
- Version 2.0, January 2004
3
- http://www.apache.org/licenses/
4
-
5
- TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
-
7
- 1. Definitions.
8
-
9
- "License" shall mean the terms and conditions for use, reproduction,
10
- and distribution as defined by Sections 1 through 9 of this document.
11
-
12
- "Licensor" shall mean the copyright owner or entity authorized by
13
- the copyright owner that is granting the License.
14
-
15
- "Legal Entity" shall mean the union of the acting entity and all
16
- other entities that control, are controlled by, or are under common
17
- control with that entity. For the purposes of this definition,
18
- "control" means (i) the power, direct or indirect, to cause the
19
- direction or management of such entity, whether by contract or
20
- otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
- outstanding shares, or (iii) beneficial ownership of such entity.
22
-
23
- "You" (or "Your") shall mean an individual or Legal Entity
24
- exercising permissions granted by this License.
25
-
26
- "Source" form shall mean the preferred form for making modifications,
27
- including but not limited to software source code, documentation
28
- source, and configuration files.
29
-
30
- "Object" form shall mean any form resulting from mechanical
31
- transformation or translation of a Source form, including but
32
- not limited to compiled object code, generated documentation,
33
- and conversions to other media types.
34
-
35
- "Work" shall mean the work of authorship, whether in Source or
36
- Object form, made available under the License, as indicated by a
37
- copyright notice that is included in or attached to the work
38
- (an example is provided in the Appendix below).
39
-
40
- "Derivative Works" shall mean any work, whether in Source or Object
41
- form, that is based on (or derived from) the Work and for which the
42
- editorial revisions, annotations, elaborations, or other modifications
43
- represent, as a whole, an original work of authorship. For the purposes
44
- of this License, Derivative Works shall not include works that remain
45
- separable from, or merely link (or bind by name) to the interfaces of,
46
- the Work and Derivative Works thereof.
47
-
48
- "Contribution" shall mean any work of authorship, including
49
- the original version of the Work and any modifications or additions
50
- to that Work or Derivative Works thereof, that is intentionally
51
- submitted to Licensor for inclusion in the Work by the copyright owner
52
- or by an individual or Legal Entity authorized to submit on behalf of
53
- the copyright owner. For the purposes of this definition, "submitted"
54
- means any form of electronic, verbal, or written communication sent
55
- to the Licensor or its representatives, including but not limited to
56
- communication on electronic mailing lists, source code control systems,
57
- and issue tracking systems that are managed by, or on behalf of, the
58
- Licensor for the purpose of discussing and improving the Work, but
59
- excluding communication that is conspicuously marked or otherwise
60
- designated in writing by the copyright owner as "Not a Contribution."
61
-
62
- "Contributor" shall mean Licensor and any individual or Legal Entity
63
- on behalf of whom a Contribution has been received by Licensor and
64
- subsequently incorporated within the Work.
65
-
66
- 2. Grant of Copyright License. Subject to the terms and conditions of
67
- this License, each Contributor hereby grants to You a perpetual,
68
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
- copyright license to reproduce, prepare Derivative Works of,
70
- publicly display, publicly perform, sublicense, and distribute the
71
- Work and such Derivative Works in Source or Object form.
72
-
73
- 3. Grant of Patent License. Subject to the terms and conditions of
74
- this License, each Contributor hereby grants to You a perpetual,
75
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
- (except as stated in this section) patent license to make, have made,
77
- use, offer to sell, sell, import, and otherwise transfer the Work,
78
- where such license applies only to those patent claims licensable
79
- by such Contributor that are necessarily infringed by their
80
- Contribution(s) alone or by combination of their Contribution(s)
81
- with the Work to which such Contribution(s) was submitted. If You
82
- institute patent litigation against any entity (including a
83
- cross-claim or counterclaim in a lawsuit) alleging that the Work
84
- or a Contribution incorporated within the Work constitutes direct
85
- or contributory patent infringement, then any patent licenses
86
- granted to You under this License for that Work shall terminate
87
- as of the date such litigation is filed.
88
-
89
- 4. Redistribution. You may reproduce and distribute copies of the
90
- Work or Derivative Works thereof in any medium, with or without
91
- modifications, and in Source or Object form, provided that You
92
- meet the following conditions:
93
-
94
- (a) You must give any other recipients of the Work or
95
- Derivative Works a copy of this License; and
96
-
97
- (b) You must cause any modified files to carry prominent notices
98
- stating that You changed the files; and
99
-
100
- (c) You must retain, in the Source form of any Derivative Works
101
- that You distribute, all copyright, patent, trademark, and
102
- attribution notices from the Source form of the Work,
103
- excluding those notices that do not pertain to any part of
104
- the Derivative Works; and
105
-
106
- (d) If the Work includes a "NOTICE" text file as part of its
107
- distribution, then any Derivative Works that You distribute must
108
- include a readable copy of the attribution notices contained
109
- within such NOTICE file, excluding those notices that do not
110
- pertain to any part of the Derivative Works, in at least one
111
- of the following places: within a NOTICE text file distributed
112
- as part of the Derivative Works; within the Source form or
113
- documentation, if provided along with the Derivative Works; or,
114
- within a display generated by the Derivative Works, if and
115
- wherever such third-party notices normally appear. The contents
116
- of the NOTICE file are for informational purposes only and
117
- do not modify the License. You may add Your own attribution
118
- notices within Derivative Works that You distribute, alongside
119
- or as an addendum to the NOTICE text from the Work, provided
120
- that such additional attribution notices cannot be construed
121
- as modifying the License.
122
-
123
- You may add Your own copyright statement to Your modifications and
124
- may provide additional or different license terms and conditions
125
- for use, reproduction, or distribution of Your modifications, or
126
- for any such Derivative Works as a whole, provided Your use,
127
- reproduction, and distribution of the Work otherwise complies with
128
- the conditions stated in this License.
129
-
130
- 5. Submission of Contributions. Unless You explicitly state otherwise,
131
- any Contribution intentionally submitted for inclusion in the Work
132
- by You to the Licensor shall be under the terms and conditions of
133
- this License, without any additional terms or conditions.
134
- Notwithstanding the above, nothing herein shall supersede or modify
135
- the terms of any separate license agreement you may have executed
136
- with Licensor regarding such Contributions.
137
-
138
- 6. Trademarks. This License does not grant permission to use the trade
139
- names, trademarks, service marks, or product names of the Licensor,
140
- except as required for reasonable and customary use in describing the
141
- origin of the Work and reproducing the content of the NOTICE file.
142
-
143
- 7. Disclaimer of Warranty. Unless required by applicable law or
144
- agreed to in writing, Licensor provides the Work (and each
145
- Contributor provides its Contributions) on an "AS IS" BASIS,
146
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
- implied, including, without limitation, any warranties or conditions
148
- of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
- PARTICULAR PURPOSE. You are solely responsible for determining the
150
- appropriateness of using or redistributing the Work and assume any
151
- risks associated with Your exercise of permissions under this License.
152
-
153
- 8. Limitation of Liability. In no event and under no legal theory,
154
- whether in tort (including negligence), contract, or otherwise,
155
- unless required by applicable law (such as deliberate and grossly
156
- negligent acts) or agreed to in writing, shall any Contributor be
157
- liable to You for damages, including any direct, indirect, special,
158
- incidental, or consequential damages of any character arising as a
159
- result of this License or out of the use or inability to use the
160
- Work (including but not limited to damages for loss of goodwill,
161
- work stoppage, computer failure or malfunction, or any and all
162
- other commercial damages or losses), even if such Contributor
163
- has been advised of the possibility of such damages.
164
-
165
- 9. Accepting Warranty or Additional Liability. While redistributing
166
- the Work or Derivative Works thereof, You may choose to offer,
167
- and charge a fee for, acceptance of support, warranty, indemnity,
168
- or other liability obligations and/or rights consistent with this
169
- License. However, in accepting such obligations, You may act only
170
- on Your own behalf and on Your sole responsibility, not on behalf
171
- of any other Contributor, and only if You agree to indemnify,
172
- defend, and hold each Contributor harmless for any liability
173
- incurred by, or claims asserted against, such Contributor by reason
174
- of your accepting any such warranty or additional liability.
175
-
176
- END OF TERMS AND CONDITIONS
1
+
2
+
3
+
4
+ Licening for the CO2.js library Apache License
5
+ =================================================================
6
+
7
+
8
+ Version 2.0, January 2004
9
+ http://www.apache.org/licenses/
10
+
11
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
12
+
13
+ 1. Definitions.
14
+
15
+ "License" shall mean the terms and conditions for use, reproduction,
16
+ and distribution as defined by Sections 1 through 9 of this document.
17
+
18
+ "Licensor" shall mean the copyright owner or entity authorized by
19
+ the copyright owner that is granting the License.
20
+
21
+ "Legal Entity" shall mean the union of the acting entity and all
22
+ other entities that control, are controlled by, or are under common
23
+ control with that entity. For the purposes of this definition,
24
+ "control" means (i) the power, direct or indirect, to cause the
25
+ direction or management of such entity, whether by contract or
26
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
27
+ outstanding shares, or (iii) beneficial ownership of such entity.
28
+
29
+ "You" (or "Your") shall mean an individual or Legal Entity
30
+ exercising permissions granted by this License.
31
+
32
+ "Source" form shall mean the preferred form for making modifications,
33
+ including but not limited to software source code, documentation
34
+ source, and configuration files.
35
+
36
+ "Object" form shall mean any form resulting from mechanical
37
+ transformation or translation of a Source form, including but
38
+ not limited to compiled object code, generated documentation,
39
+ and conversions to other media types.
40
+
41
+ "Work" shall mean the work of authorship, whether in Source or
42
+ Object form, made available under the License, as indicated by a
43
+ copyright notice that is included in or attached to the work
44
+ (an example is provided in the Appendix below).
45
+
46
+ "Derivative Works" shall mean any work, whether in Source or Object
47
+ form, that is based on (or derived from) the Work and for which the
48
+ editorial revisions, annotations, elaborations, or other modifications
49
+ represent, as a whole, an original work of authorship. For the purposes
50
+ of this License, Derivative Works shall not include works that remain
51
+ separable from, or merely link (or bind by name) to the interfaces of,
52
+ the Work and Derivative Works thereof.
53
+
54
+ "Contribution" shall mean any work of authorship, including
55
+ the original version of the Work and any modifications or additions
56
+ to that Work or Derivative Works thereof, that is intentionally
57
+ submitted to Licensor for inclusion in the Work by the copyright owner
58
+ or by an individual or Legal Entity authorized to submit on behalf of
59
+ the copyright owner. For the purposes of this definition, "submitted"
60
+ means any form of electronic, verbal, or written communication sent
61
+ to the Licensor or its representatives, including but not limited to
62
+ communication on electronic mailing lists, source code control systems,
63
+ and issue tracking systems that are managed by, or on behalf of, the
64
+ Licensor for the purpose of discussing and improving the Work, but
65
+ excluding communication that is conspicuously marked or otherwise
66
+ designated in writing by the copyright owner as "Not a Contribution."
67
+
68
+ "Contributor" shall mean Licensor and any individual or Legal Entity
69
+ on behalf of whom a Contribution has been received by Licensor and
70
+ subsequently incorporated within the Work.
71
+
72
+ 2. Grant of Copyright License. Subject to the terms and conditions of
73
+ this License, each Contributor hereby grants to You a perpetual,
74
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
75
+ copyright license to reproduce, prepare Derivative Works of,
76
+ publicly display, publicly perform, sublicense, and distribute the
77
+ Work and such Derivative Works in Source or Object form.
78
+
79
+ 3. Grant of Patent License. Subject to the terms and conditions of
80
+ this License, each Contributor hereby grants to You a perpetual,
81
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
82
+ (except as stated in this section) patent license to make, have made,
83
+ use, offer to sell, sell, import, and otherwise transfer the Work,
84
+ where such license applies only to those patent claims licensable
85
+ by such Contributor that are necessarily infringed by their
86
+ Contribution(s) alone or by combination of their Contribution(s)
87
+ with the Work to which such Contribution(s) was submitted. If You
88
+ institute patent litigation against any entity (including a
89
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
90
+ or a Contribution incorporated within the Work constitutes direct
91
+ or contributory patent infringement, then any patent licenses
92
+ granted to You under this License for that Work shall terminate
93
+ as of the date such litigation is filed.
94
+
95
+ 4. Redistribution. You may reproduce and distribute copies of the
96
+ Work or Derivative Works thereof in any medium, with or without
97
+ modifications, and in Source or Object form, provided that You
98
+ meet the following conditions:
99
+
100
+ (a) You must give any other recipients of the Work or
101
+ Derivative Works a copy of this License; and
102
+
103
+ (b) You must cause any modified files to carry prominent notices
104
+ stating that You changed the files; and
105
+
106
+ (c) You must retain, in the Source form of any Derivative Works
107
+ that You distribute, all copyright, patent, trademark, and
108
+ attribution notices from the Source form of the Work,
109
+ excluding those notices that do not pertain to any part of
110
+ the Derivative Works; and
111
+
112
+ (d) If the Work includes a "NOTICE" text file as part of its
113
+ distribution, then any Derivative Works that You distribute must
114
+ include a readable copy of the attribution notices contained
115
+ within such NOTICE file, excluding those notices that do not
116
+ pertain to any part of the Derivative Works, in at least one
117
+ of the following places: within a NOTICE text file distributed
118
+ as part of the Derivative Works; within the Source form or
119
+ documentation, if provided along with the Derivative Works; or,
120
+ within a display generated by the Derivative Works, if and
121
+ wherever such third-party notices normally appear. The contents
122
+ of the NOTICE file are for informational purposes only and
123
+ do not modify the License. You may add Your own attribution
124
+ notices within Derivative Works that You distribute, alongside
125
+ or as an addendum to the NOTICE text from the Work, provided
126
+ that such additional attribution notices cannot be construed
127
+ as modifying the License.
128
+
129
+ You may add Your own copyright statement to Your modifications and
130
+ may provide additional or different license terms and conditions
131
+ for use, reproduction, or distribution of Your modifications, or
132
+ for any such Derivative Works as a whole, provided Your use,
133
+ reproduction, and distribution of the Work otherwise complies with
134
+ the conditions stated in this License.
135
+
136
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
137
+ any Contribution intentionally submitted for inclusion in the Work
138
+ by You to the Licensor shall be under the terms and conditions of
139
+ this License, without any additional terms or conditions.
140
+ Notwithstanding the above, nothing herein shall supersede or modify
141
+ the terms of any separate license agreement you may have executed
142
+ with Licensor regarding such Contributions.
143
+
144
+ 6. Trademarks. This License does not grant permission to use the trade
145
+ names, trademarks, service marks, or product names of the Licensor,
146
+ except as required for reasonable and customary use in describing the
147
+ origin of the Work and reproducing the content of the NOTICE file.
148
+
149
+ 7. Disclaimer of Warranty. Unless required by applicable law or
150
+ agreed to in writing, Licensor provides the Work (and each
151
+ Contributor provides its Contributions) on an "AS IS" BASIS,
152
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
153
+ implied, including, without limitation, any warranties or conditions
154
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
155
+ PARTICULAR PURPOSE. You are solely responsible for determining the
156
+ appropriateness of using or redistributing the Work and assume any
157
+ risks associated with Your exercise of permissions under this License.
158
+
159
+ 8. Limitation of Liability. In no event and under no legal theory,
160
+ whether in tort (including negligence), contract, or otherwise,
161
+ unless required by applicable law (such as deliberate and grossly
162
+ negligent acts) or agreed to in writing, shall any Contributor be
163
+ liable to You for damages, including any direct, indirect, special,
164
+ incidental, or consequential damages of any character arising as a
165
+ result of this License or out of the use or inability to use the
166
+ Work (including but not limited to damages for loss of goodwill,
167
+ work stoppage, computer failure or malfunction, or any and all
168
+ other commercial damages or losses), even if such Contributor
169
+ has been advised of the possibility of such damages.
170
+
171
+ 9. Accepting Warranty or Additional Liability. While redistributing
172
+ the Work or Derivative Works thereof, You may choose to offer,
173
+ and charge a fee for, acceptance of support, warranty, indemnity,
174
+ or other liability obligations and/or rights consistent with this
175
+ License. However, in accepting such obligations, You may act only
176
+ on Your own behalf and on Your sole responsibility, not on behalf
177
+ of any other Contributor, and only if You agree to indemnify,
178
+ defend, and hold each Contributor harmless for any liability
179
+ incurred by, or claims asserted against, such Contributor by reason
180
+ of your accepting any such warranty or additional liability.
181
+
182
+ END OF TERMS AND CONDITIONS
183
+
184
+
185
+ Data Licences
186
+ =================================================================
187
+
188
+ Average Carbon intensity Data
189
+ -----------------------------------------------------------------
190
+
191
+ The average carbon intensity data bundled in CO2.js is republished from Ember Climate, under the same CC-BY-SA licencing terms.
192
+
193
+ Please see the full licence at the link below for more along with any further disclaimers about liability for use. For convenience we republish the body of the disclaimer below, along with a link to full methodology information:
194
+
195
+ "The data used in this library is provided on an ‘as is’ basis. Data is assembled using the best available data at the time of publication. Every effort has been made to ensure accuracy, and where possible we compare multiple sources to confirm their agreement. We take no responsibility for errors."
196
+
197
+ https://ember-climate.org/creative-commons/
198
+ https://ember-climate.org/insights/research/global-electricity-review-2022/
199
+
200
+
201
+ Marginal Carbon intensity data
202
+ -----------------------------------------------------------------
203
+
204
+ The marginal carbon intensity data bundled in CO2.js is published by the Green Web Foundation under the same permissive CC-BY-SA license as the average carbon intensity data. This data is largely based on the operating marginal intensity data published by International Financial Institutions Technical Working group (the IFI TWG) project within the United Nations Framework Convention on Climate Change (the UNFCCC), to harmonize project-level greenhouse gas emissions accounting.
205
+
206
+ The data used in this report is provided on an ‘as is’ basis. Data is assembled using the best available data at the time of publication. Every effort has been made to ensure accuracy, and where possible we compare multiple sources to confirm their agreement. We take no responsibility for errors.
207
+
208
+
209
+ For further information about the methodology used, see the following links
210
+
211
+ https://developers.thegreenwebfoundation.org/co2js/data/
212
+ https://unfccc.int/climate-action/sectoral-engagement/ifis-harmonization-of-standards-for-ghg-accounting
213
+ https://unfccc.int/sites/default/files/resource/IFITWG_Methodological_approach_to_common_dataset.pdf
214
+
215
+
package/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  <img src="https://github.com/thegreenwebfoundation/co2.js/actions/workflows/unittests.yml/badge.svg" />
4
4
 
5
- One day, there internet will be powered by renewable energy. Until that day comes, there’ll be a CO2 cost that comes with every byte of data that’s uploaded or downloaded. By being able to calculate these emissions, developers can be empowered to create more efficient, lower carbon apps, websites, and software.
5
+ One day, the internet will be powered by renewable energy. Until that day comes, there’ll be a CO2 cost that comes with every byte of data that’s uploaded or downloaded. By being able to calculate these emissions, developers can be empowered to create more efficient, lower carbon apps, websites, and software.
6
6
 
7
7
  ## [Documentation](https://developers.thegreenwebfoundation.org/co2js/overview/)
8
8
  ## [Changelog](/CHANGELOG.md)
@@ -39,6 +39,25 @@ You can import the CO2.js library into projects using Skypack.
39
39
  import tgwf from 'https://cdn.skypack.dev/@tgwf/co2';
40
40
  ```
41
41
 
42
+ ## Using a JS CDN
43
+
44
+ You can get the latest version of CO2.js using one of the content delivery networks below.
45
+
46
+ ### jsDelivr
47
+
48
+ You can find the package at [https://www.jsdelivr.com/package/npm/@tgwf/co2](https://www.jsdelivr.com/package/npm/@tgwf/co2).
49
+
50
+ - CommonJS compatible build `https://cdn.jsdelivr.net/npm/@tgwf/co2@latest/dist/cjs/index-node.min.js`
51
+ - ES Modules compatible build `https://cdn.jsdelivr.net/npm/@tgwf/co2@latest/dist/esm/index.js`
52
+ - IIFE compatible build `https://cdn.jsdelivr.net/npm/@tgwf/co2@latest/dist/iife/index.js`
53
+
54
+ ### Unpkgd
55
+
56
+ You can find the package at [https://unpkg.com/browse/@tgwf/co2@latest/](https://unpkg.com/browse/@tgwf/co2@latest/).
57
+
58
+ - CommonJS compatible build `https://unpkg.com/@tgwf/co2@latest/dist/cjs/index-node.min.js`
59
+ - ES Modules compatible build `https://unpkg.com/@tgwf/co2@latest/dist/esm/index.js`
60
+ - IIFE compatible build `https://unpkg.com/@tgwf/co2@latest/dist/iife/index.js`
42
61
 
43
62
  ### Build it yourself
44
63
 
@@ -53,6 +72,22 @@ You can also build the CO2.js library from the source code. To do this:
53
72
  - `dist/esm` - An ES Modules compatible build.
54
73
  - `dist/iife` - An Immediately Invoked Function Expression (IIFE) version of the library.
55
74
 
75
+ ## Marginal and average emissions intensity data
76
+
77
+ CO2.js includes yearly average grid intensity data from [Ember](https://ember-climate.org/data/data-explorer/), as well as marginal intensity data from the [UNFCCC](https://unfccc.int/) (United Nations Framework Convention on Climate Change). You can find the data in JSON and CommonJS Module format in the `data/output` folder.
78
+
79
+ ### Using emissions intensity data
80
+
81
+ You can import annual, country-level marginal or average grid intensity data into your projects directly from CO2.js. For example, if we wanted to use the average grid intensity for Australia in our project, we could use the code below:
82
+
83
+ ```js
84
+ import { averageIntensity } from '@tgwf/co2';
85
+ const { data } = averageIntensity;
86
+ const { AUS } = data;
87
+ console.log({ AUS })
88
+ ```
89
+
90
+ All countries are represented by their respective [Alpha-3 ISO country code](https://www.iso.org/obp/ui/#search).
56
91
  ## Publishing to NPM
57
92
 
58
93
  We use [`np`](https://www.npmjs.com/package/np) to publish new versions of this library to NPM. To do this:
@@ -61,6 +96,14 @@ We use [`np`](https://www.npmjs.com/package/np) to publish new versions of this
61
96
  2. Then run `npx np <VERSION>`.
62
97
  3. `np` will run several automated steps to publish the new package to NPM.
63
98
  4. If everything runs successfully, you can then add release notes to GitHub for the newly published package.
99
+
100
+
64
101
  ## Licenses
65
102
 
66
- Apache 2.0
103
+ The code for CO2.js is licensed Apache 2.0.
104
+
105
+ The average carbon intensity data from Ember is published under the Creative Commons ShareAlike Attribution Licence ([CC BY-SA 4.0](https://creativecommons.org/licenses/by-sa/4.0/))
106
+
107
+ The marginal intensity data is published by the Green Web Foundation, under the Creative Commons ShareAlike Attribution Licence ([CC BY-SA 4.0](https://creativecommons.org/licenses/by-sa/4.0/)).
108
+
109
+ See LICENCE for more.
@@ -0,0 +1,7 @@
1
+ node_modules
2
+
3
+ # Ignore data files that are not generated
4
+ fixtures
5
+ functions
6
+ utils
7
+ *.min.js