@@ -15,14 +15,12 @@ const csv = fs.readFileSync(
1515 "data/IFI_Default_Grid_Factors_2021_v3.1_unfccc.csv"
1616) ;
1717
18-
1918/**
2019 * Utility function to parse CSV rows.
2120 * @type {function }
2221 */
2322const parseCSVRow = require ( "../utils/parseCSVRow" ) ;
2423
25-
2624/**
2725 * Utility function to get country codes.
2826 * @type {function }
@@ -47,21 +45,18 @@ const source = "UNFCCC";
4745 */
4846const year = "2021" ;
4947
50-
5148/**
5249 * Converts the CSV data to an array of strings, each representing a row.
5350 * @type {string[] }
5451 */
5552const array = csv . toString ( ) . split ( "\n" ) ;
5653
57-
5854/**
5955 * Object to store the converted CSV data.
6056 * @type {Object.<string, Object> }
6157 */
6258const csvToJsonResult = { } ;
6359
64-
6560/**
6661 * Object to store the grid intensity results for each country.
6762 * @type {Object.<string, string> }
@@ -133,6 +128,17 @@ for (let currentArrayString of array.slice(5)) {
133128const json = JSON . stringify ( csvToJsonResult ) ;
134129const gridIntensityJson = JSON . stringify ( gridIntensityResults ) ;
135130
131+ const jsDocComments = `/**
132+ * @fileoverview Minified marginal CO2 emissions intensity data for countries (2021).
133+ * @generated Generated by generate_marginal_co2.js
134+ * @version 1.0.0
135+ */
136+
137+ /**
138+ * @constant {Object.<string, number>} data - Average CO2 emissions intensity data for various countries.
139+ * @constant {string} type - Type of data being represented.
140+ * @constant {string} year - Year for which the data was collected.
141+ */` ;
136142
137143/**
138144 * Saves the country code and emissions data for use in the CO2.js library.
@@ -149,17 +155,16 @@ fs.writeFileSync(
149155 `
150156) ;
151157
152-
153158/**
154159 * Saves a minified version of the data for easy import into the library.
155160 * @type {void }
156161 */
157162fs . writeFileSync (
158163 "src/data/marginal-intensities-2021.min.js" ,
159- `const data = ${ gridIntensityJson } ; const type = "${ type } "; const year = "${ year } "; export { data, type, year }; export default { data, type, year };`
164+ `${ jsDocComments }
165+ const data = ${ gridIntensityJson } ; const type = "${ type } "; const year = "${ year } "; export { data, type, year }; export default { data, type, year };`
160166) ;
161167
162-
163168/**
164169 * Saves the full data set as a JSON file for reference.
165170 * @type {void }
0 commit comments