@things-factory/dataset 6.0.78 → 6.0.79

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": "@things-factory/dataset",
3
- "version": "6.0.78",
3
+ "version": "6.0.79",
4
4
  "main": "dist-server/index.js",
5
5
  "browser": "dist-client/index.js",
6
6
  "things-factory": true,
@@ -50,5 +50,5 @@
50
50
  "simple-statistics": "^7.8.3",
51
51
  "statistics": "^3.3.0"
52
52
  },
53
- "gitHead": "6d1b076baae617ee1c1df25e176c21d7b1a18e61"
53
+ "gitHead": "a7638563e82d7daf5c105caf1ee62fc4ce6f98dc"
54
54
  }
@@ -65,14 +65,23 @@ const calculateSummary = (dataItems: DataItem[], base: { [tag: string]: any[] })
65
65
  .map(Number)
66
66
  .filter(item => !isNaN(item))
67
67
 
68
- switch (item.stat) {
69
- case 'range':
70
- summary[tag] = statistics.max(data) - statistics.min(data)
71
- break
72
-
73
- default:
74
- const functionName = STAT_FUNCTION_MAP[item.stat]
75
- summary[tag] = (functionName && statistics[functionName](data)) || ''
68
+ if (data.length > 0) {
69
+ try {
70
+ switch (item.stat) {
71
+ case 'range':
72
+ summary[tag] = statistics.max(data) - statistics.min(data)
73
+ break
74
+
75
+ default:
76
+ const functionName = STAT_FUNCTION_MAP[item.stat]
77
+ summary[tag] = (functionName && statistics[functionName](data)) || ''
78
+ }
79
+ } catch (err) {
80
+ summary[tag] = null
81
+ console.error(err)
82
+ }
83
+ } else {
84
+ summary[tag] = null
76
85
  }
77
86
 
78
87
  return summary