@tgwf/co2 0.9.0 → 0.10.2

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 (92) hide show
  1. package/.esbuild.browser.js +11 -0
  2. package/.esbuild.esm.js +25 -0
  3. package/.esbuild.node.js +16 -0
  4. package/.gitpod.yml +8 -0
  5. package/CHANGELOG.md +22 -1
  6. package/README.md +29 -66
  7. package/dist/cjs/1byte.js +52 -0
  8. package/dist/cjs/1byte.js.map +7 -0
  9. package/dist/cjs/1byte.test.js +27 -0
  10. package/dist/cjs/1byte.test.js.map +7 -0
  11. package/dist/cjs/co2.js +121 -0
  12. package/dist/cjs/co2.js.map +7 -0
  13. package/dist/cjs/co2.test.js +258 -0
  14. package/dist/cjs/co2.test.js.map +7 -0
  15. package/dist/cjs/constants/file-size.js +27 -0
  16. package/dist/cjs/constants/file-size.js.map +7 -0
  17. package/dist/cjs/constants/index.js +27 -0
  18. package/dist/cjs/constants/index.js.map +7 -0
  19. package/dist/cjs/helpers/index.js +24 -0
  20. package/dist/cjs/helpers/index.js.map +7 -0
  21. package/dist/cjs/hosting-api.js +64 -0
  22. package/dist/cjs/hosting-api.js.map +7 -0
  23. package/dist/cjs/hosting-api.test.js +47 -0
  24. package/dist/cjs/hosting-api.test.js.map +7 -0
  25. package/dist/cjs/hosting-database.node.test.js +36 -0
  26. package/dist/cjs/hosting-database.node.test.js.map +7 -0
  27. package/dist/cjs/hosting-json.node.js +73 -0
  28. package/dist/cjs/hosting-json.node.js.map +7 -0
  29. package/dist/cjs/hosting-json.node.test.js +43 -0
  30. package/dist/cjs/hosting-json.node.test.js.map +7 -0
  31. package/dist/cjs/hosting-node.js +78 -0
  32. package/dist/cjs/hosting-node.js.map +7 -0
  33. package/dist/cjs/hosting.js +36 -0
  34. package/dist/cjs/hosting.js.map +7 -0
  35. package/dist/cjs/hosting.test.js +74 -0
  36. package/dist/cjs/hosting.test.js.map +7 -0
  37. package/dist/cjs/index-node.js +29 -0
  38. package/dist/cjs/index-node.js.map +7 -0
  39. package/dist/cjs/index.js +31 -0
  40. package/dist/cjs/index.js.map +7 -0
  41. package/dist/cjs/package.json +3 -0
  42. package/dist/cjs/sustainable-web-design.js +134 -0
  43. package/dist/cjs/sustainable-web-design.js.map +7 -0
  44. package/dist/cjs/sustainable-web-design.test.js +79 -0
  45. package/dist/cjs/sustainable-web-design.test.js.map +7 -0
  46. package/dist/esm/1byte.js +32 -0
  47. package/dist/esm/1byte.test.js +11 -0
  48. package/dist/esm/co2.js +98 -0
  49. package/{src → dist/esm}/co2.test.js +47 -94
  50. package/dist/esm/constants/file-size.js +7 -0
  51. package/dist/esm/constants/index.js +4 -0
  52. package/dist/esm/helpers/index.js +4 -0
  53. package/dist/esm/hosting-api.js +41 -0
  54. package/dist/esm/hosting-api.test.js +31 -0
  55. package/{src/hosting-database.test.js → dist/esm/hosting-database.node.test.js} +7 -18
  56. package/{src/hosting-json.test.js → dist/esm/hosting-json.node.test.js} +4 -21
  57. package/dist/esm/hosting.js +13 -0
  58. package/{src → dist/esm}/hosting.test.js +10 -30
  59. package/dist/esm/index.js +8 -0
  60. package/dist/esm/package.json +3 -0
  61. package/dist/esm/sustainable-web-design.js +111 -0
  62. package/{src → dist/esm}/sustainable-web-design.test.js +19 -37
  63. package/dist/iife/index.js +2 -0
  64. package/dist/iife/index.js.map +7 -0
  65. package/fixup +19 -0
  66. package/package.json +38 -17
  67. package/public/index.html +58 -0
  68. package/public/index.js +2 -0
  69. package/src/1byte.js +2 -3
  70. package/src/co2.js +17 -18
  71. package/src/constants/file-size.js +2 -2
  72. package/src/constants/index.js +2 -2
  73. package/src/helpers/index.js +1 -3
  74. package/src/hosting-api.js +23 -43
  75. package/src/{hosting-json.js → hosting-json.node.js} +9 -11
  76. package/src/hosting-node.js +94 -0
  77. package/src/hosting.js +6 -28
  78. package/src/index-node.js +4 -0
  79. package/src/index.js +4 -6
  80. package/src/sustainable-web-design.js +37 -11
  81. package/.eslintrc.json +0 -21
  82. package/.github/workflows/unittests.yml +0 -26
  83. package/data/Lean-ICT-Materials-1byte-Model-2018.xlsx +0 -0
  84. package/data/Lean-ICT-Materials-Forecast-Model-2018.xlsx +0 -0
  85. package/data/fixtures/tgwf.har +0 -6107
  86. package/data/fixtures/url2green.test.db +0 -0
  87. package/data/fixtures/url2green.test.json +0 -1
  88. package/data/fixtures/url2green.test.json.gz +0 -0
  89. package/images/swd-energy-usage.png +0 -0
  90. package/src/1byte.test.js +0 -17
  91. package/src/green-byte.js +0 -26
  92. package/src/hosting-api.test.js +0 -37
Binary file
@@ -1 +0,0 @@
1
- ["google.com","maxcdn.bootstrapcdn.com","thegreenwebfoundation.org","www.thegreenwebfoundation.org","fonts.googleapis.com","ajax.googleapis.com","assets.digitalclimatestrike.net","cdnjs.cloudflare.com","graphite.thegreenwebfoundation.org","analytics.thegreenwebfoundation.org","fonts.gstatic.com","api.thegreenwebfoundation.org"]
Binary file
package/src/1byte.test.js DELETED
@@ -1,17 +0,0 @@
1
- "use strict";
2
-
3
- const oneByte = require("./1byte");
4
-
5
- describe("onebyte", () => {
6
- describe("perByte", () => {
7
- it.only("returns a simple average of the different networks", () => {
8
- // we limit this to 12 figures with toFixed(12), because
9
- // we have a recurring 333333 afterwards
10
- // 4.88e-10 is the same as 0.000000000488
11
- const expected_val = (0.000000000488).toFixed(12);
12
- const instance = new oneByte.OneByte();
13
-
14
- expect(instance.KWH_PER_BYTE_FOR_NETWORK.toFixed(12)).toBe(expected_val);
15
- });
16
- });
17
- });
package/src/green-byte.js DELETED
@@ -1,26 +0,0 @@
1
- // PLEASE DO NOT USE THIS MODEL YET FOR CALCS
2
-
3
- const CO2_PER_KWH_IN_DC_GREY = 519;
4
-
5
- // this subs in the IEA's recent figure in analyis from the carbon brief
6
- // https://www.carbonbrief.org/factcheck-what-is-the-carbon-footprint-of-streaming-video-on-netflix
7
-
8
- // datacentres
9
- const KWH_PER_BYTE_IN_DC = 0.00000000007;
10
-
11
- // networks
12
- const KWH_PER_BYTE_FOR_NETWORK = 0.00000000058;
13
-
14
- // the device used to access a site/app
15
- const KWH_PER_BYTE_FOR_DEVICES = 0.00000000055;
16
-
17
- // The device usage figure combines figures for:
18
- // 1. the usage for devices (which is small proportion of the energy use)
19
- // 2. the *making* the device, which is comparitively high.
20
-
21
- module.exports = {
22
- KWH_PER_BYTE_IN_DC,
23
- KWH_PER_BYTE_FOR_NETWORK,
24
- KWH_PER_BYTE_FOR_DEVICES,
25
- CO2_PER_KWH_IN_DC_GREY,
26
- };
@@ -1,37 +0,0 @@
1
- "use strict";
2
-
3
- const hosting = require("./hosting-api");
4
- const nock = require("nock");
5
-
6
- describe("hostingAPI", () => {
7
- describe("checking a single domain with #check", () => {
8
- it("using the API", async () => {
9
- const scope = nock("https://api.thegreenwebfoundation.org/")
10
- .get("/greencheck/google.com")
11
- .reply(200, {
12
- url: "google.com",
13
- green: true,
14
- });
15
- const res = await hosting.check("google.com");
16
- expect(res).toEqual(true);
17
- });
18
- });
19
- describe("implicitly checking multiple domains with #check", () => {
20
- it("using the API", async () => {
21
- const scope = nock("https://api.thegreenwebfoundation.org/")
22
- .get("/v2/greencheckmulti/[%22google.com%22,%22kochindustries.com%22]")
23
- .reply(200, {
24
- "google.com": {
25
- url: "google.com",
26
- green: true,
27
- },
28
- "kochindustries.com": {
29
- url: "kochindustries.com",
30
- green: null,
31
- },
32
- });
33
- const res = await hosting.check(["google.com", "kochindustries.com"]);
34
- expect(res).toContain("google.com");
35
- });
36
- });
37
- });