@hestia-earth/glossary 0.90.0 → 0.91.1

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.
package/index.js CHANGED
@@ -7,7 +7,8 @@ const loadResource = (filename) => require(`./resources/${filename}`);
7
7
  * @param {string} key The key in the resource file.
8
8
  * @returns {any} The data associated with the `key`.
9
9
  */
10
- const loadResourceKey = (filename, key) => loadResource(filename)[key];
10
+ const loadResourceKey = (filename, key) =>
11
+ key ? loadResource(filename)[key] : loadResource(filename);
11
12
 
12
13
  /**
13
14
  * Converts the iso31662 code to the [term.name](https://hestia.earth/schema/Term#name) from the HESTIA Glossary.
@@ -111,11 +112,19 @@ const getEcoinventMapping = (id) =>
111
112
  const getWorldSteelMapping = (id) =>
112
113
  loadResourceKey("worldsteelMapping.json", id);
113
114
 
114
- const getBafuMapping = (id) =>
115
- loadResourceKey("bafuMapping.json", id);
115
+ const getBafuMapping = (id) => loadResourceKey("bafuMapping.json", id);
116
116
 
117
117
  const getBlankNodesGroup = (id) => loadResourceKey("blankNodesGroup.json", id);
118
118
 
119
+ /**
120
+ * Get the groupings for the Emission.
121
+ *
122
+ * @param {string} id The HESTIA term [id](https://hestia.earth/schema/Term#id).
123
+ * @returns {object} Different groupings types and values.
124
+ */
125
+ const getEmissionGroupings = (id) =>
126
+ loadResourceKey("emission-groupings.json", id);
127
+
119
128
  /**
120
129
  * Determines if the property is identifying a cover crop.
121
130
  *
@@ -146,10 +155,10 @@ const termOrder = ({ "@id": id, termType }) => {
146
155
  ? data[termType].indexOf(id)
147
156
  : data[termType]
148
157
  : id
149
- ? Object.values(data)
150
- .find((values) => values.includes(id))
151
- ?.indexOf(id)
152
- : -1;
158
+ ? Object.values(data)
159
+ .find((values) => values.includes(id))
160
+ ?.indexOf(id)
161
+ : -1;
153
162
  };
154
163
 
155
164
  module.exports = {
@@ -169,6 +178,7 @@ module.exports = {
169
178
  getWorldSteelMapping,
170
179
  getBafuMapping,
171
180
  getBlankNodesGroup,
181
+ getEmissionGroupings,
172
182
  isCoverCrop,
173
183
  getModelGroup,
174
184
  termOrder,
package/package.json CHANGED
@@ -1,10 +1,11 @@
1
1
  {
2
2
  "name": "@hestia-earth/glossary",
3
- "version": "0.90.0",
3
+ "version": "0.91.1",
4
4
  "description": "HESTIA Earth Glossary library",
5
5
  "main": "index.js",
6
6
  "scripts": {
7
7
  "gen:impact-assessment": "node scripts/node/generate-impact-assessment-data.js",
8
+ "gen:emission-grouping": "node scripts/node/generate-emission-groupings.js",
8
9
  "gen:lookups-data": "node scripts/node/generate-lookups-data.js",
9
10
  "gen:model-groups": "node scripts/node/generate-model-groups-data.js",
10
11
  "gen:term-order": "node scripts/node/generate-term-order.js",