PageSourceSearch

https://global-plastics-tool.org/js/add_global_util.js

js global-plastics-tool.org collected 2026-09-26 01:14:04 UTC 1,052 bytes, 31 lines download raw bytes

1/**
2 * Calculate global statistics from region statistics for a state Map
3 *
4 * @param state The state Map in which the global statistics should be added.
5 * @param attrs All attributes to add.
6 */
7function addGlobalToStateAttrs(state, attrs) {
8    const outputs = state.get("out");
9    const globalValues = new Map();
10    attrs.forEach((attr) => {
11        const total = Array.of(...outputs.keys())
12            .filter((region) => region !== "global")
13            .map((region) => outputs.get(region))
14            .map((regionValues) => {
15                const ATTRS_TO_ZERO = [
16                    "netImportsMT",
17                    "netWasteImportMT",
18                ];
19
20                const originalValue = regionValues.get(attr);
21                if (ATTRS_TO_ZERO.indexOf(attr) != -1) {
22                    return 0;
23                } else {
24                    return originalValue;
25                }
26            })
27            .reduce((a, b) => a + b);
28        globalValues.set(attr, total);
29    });
30    outputs.set("global", globalValues);
31}

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.