og-statistics 2.0.0 → 2.0.2

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/index.js +21 -10
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "og-statistics",
3
- "version": "2.0.0",
3
+ "version": "2.0.2",
4
4
  "description": "",
5
5
  "main": "./src/index.js",
6
6
  "scripts": {
package/src/index.js CHANGED
@@ -102,17 +102,28 @@ function filterStats(statsBase, keys = def, fallback = 0) {
102
102
  card
103
103
  */
104
104
 
105
- function filterIncidents(incidents, side = false) {
105
+ function filterIncidents(incidents) {
106
106
  try {
107
107
 
108
- const cards = filterCards(incidents.incidents, side);
109
- const goals = filterGoals(incidents.incidents, side);
110
- const subs = filterSubs(incidents.incidents, side);
108
+ const home_cards = filterCards(incidents.incidents, true);
109
+ const home_goals = filterGoals(incidents.incidents, true);
110
+ const home_subs = filterSubs(incidents.incidents, true);
111
+
112
+ const away_cards = filterCards(incidents.incidents, false);
113
+ const away_goals = filterGoals(incidents.incidents, false);
114
+ const away_subs = filterSubs(incidents.incidents, false);
111
115
 
112
116
  return {
113
- cards,
114
- goals,
115
- subs
117
+ home: {
118
+ cards: home_cards,
119
+ goals: home_goals,
120
+ subs: home_subs
121
+ },
122
+ away: {
123
+ cards: away_cards,
124
+ goals: away_goals,
125
+ subs: away_subs
126
+ }
116
127
  }
117
128
 
118
129
  } catch (error) {
@@ -163,11 +174,11 @@ const filterGoals = (incidents, isHome) => {
163
174
  };
164
175
 
165
176
  function filterSubs(incidents, isHome) {
166
- const teamIncidents = incidents.filter(s => s.isHome === isHome && s.incidentType === 'substitution');
167
- const teamInjured = incidents.filter(s => s.isHome === isHome && s.incidentType === 'substitution' && s.injury === true);
177
+ let teamIncidents = incidents.filter(s => s.isHome === isHome && s.incidentType === 'substitution');
178
+ let teamInjured = incidents.filter(s => s.isHome === isHome && s.incidentType === 'substitution' && s.injury === true);
168
179
 
169
180
  return {
170
- subs: teamIncidents,
181
+ all: teamIncidents,
171
182
  injured: teamInjured
172
183
  }
173
184
  }