@sdeverywhere/compile 0.7.23 → 0.7.24

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sdeverywhere/compile",
3
- "version": "0.7.23",
3
+ "version": "0.7.24",
4
4
  "description": "The core Vensim to C compiler for the SDEverywhere tool suite.",
5
5
  "type": "module",
6
6
  "main": "./src/index.js",
@@ -24,6 +24,8 @@ let nextLevelVarSeq = 1
24
24
  let nextAuxVarSeq = 1
25
25
  // parsed csv data cache
26
26
  let csvData = new Map()
27
+ // parsed xlsx data cache
28
+ let xlsxData = new Map()
27
29
 
28
30
  // Newer versions of the xlsx package require manually setting the `fs` instance
29
31
  // before using the `XLSX.readFile` function
@@ -38,6 +40,7 @@ export function resetHelperState() {
38
40
  nextLevelVarSeq = 1
39
41
  nextAuxVarSeq = 1
40
42
  csvData.clear()
43
+ xlsxData.clear()
41
44
  }
42
45
 
43
46
  export let canonicalName = name => {
@@ -200,7 +203,15 @@ export let isIterable = obj => {
200
203
  }
201
204
  // Command helpers
202
205
  export let readXlsx = pathname => {
203
- return XLSX.readFile(pathname, { cellDates: true })
206
+ // Read the XLSX file at the pathname and parse it.
207
+ // Return a `XLSX.WorkBook` object that can be used to access the data.
208
+ // Cache parsed files to support multiple reads from different equations.
209
+ let xlsx = xlsxData.get(pathname)
210
+ if (!xlsx) {
211
+ xlsx = XLSX.readFile(pathname, { cellDates: true })
212
+ xlsxData.set(pathname, xlsx)
213
+ }
214
+ return xlsx
204
215
  }
205
216
  export let readCsv = (pathname, delimiter = ',') => {
206
217
  // Read the CSV file at the pathname and parse it with the given delimiter.
@@ -208,7 +219,7 @@ export let readCsv = (pathname, delimiter = ',') => {
208
219
  // If there is a header row, it is returned as the first row.
209
220
  // Cache parsed files to support multiple reads from different equations.
210
221
  let csv = csvData.get(pathname)
211
- if (csv == null) {
222
+ if (!csv) {
212
223
  const CSV_PARSE_OPTS = {
213
224
  delimiter,
214
225
  columns: false,