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