rategame-shared 1.1.526 → 1.1.528

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.
@@ -0,0 +1,15 @@
1
+ export declare const labelPlayerStat: (key: string) => string;
2
+ export declare const labelGameStat: (key: string) => string;
3
+ export declare const formatPlayerStat: (key: string, value: string | number) => string;
4
+ export declare const getImportantPlayerStats: (stats: Record<string, string | number>, limit?: number) => [string, string | number][];
5
+ export declare const getPlayerGameStats: (stats: Record<string, string | number | null> | undefined, league: string, position?: string) => Record<string, string | number> | undefined;
6
+ export declare const getGameLogPlayerStats: (stats: Record<string, string | number>, league: string, position?: string) => {
7
+ key: string;
8
+ label: string;
9
+ value: string | number;
10
+ }[];
11
+ export declare const getCareerPlayerStats: (seasons: Array<{
12
+ stats: Record<string, string | number>;
13
+ }>, keys: string[]) => any;
14
+ export declare const formatGameStats: (stats: Record<string, string | number> | undefined) => string;
15
+ export declare const formatGameLogStats: (stats: Record<string, string | number>, league: string, position?: string) => string;
@@ -0,0 +1,627 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.formatGameLogStats = exports.formatGameStats = exports.getCareerPlayerStats = exports.getGameLogPlayerStats = exports.getPlayerGameStats = exports.getImportantPlayerStats = exports.formatPlayerStat = exports.labelGameStat = exports.labelPlayerStat = void 0;
4
+ const soccerLeagues_1 = require("../constants/soccerLeagues");
5
+ const CAREER_AVERAGE_KEYS = [
6
+ 'avg',
7
+ 'average',
8
+ // NBA
9
+ 'min',
10
+ 'pts',
11
+ 'fgm',
12
+ 'fga',
13
+ 'fg_pct',
14
+ 'fg3m',
15
+ 'fg3a',
16
+ 'fg3_pct',
17
+ 'ftm',
18
+ 'fta',
19
+ 'ft_pct',
20
+ 'reb',
21
+ 'ast',
22
+ 'turnover',
23
+ 'stl',
24
+ 'blk',
25
+ 'oreb',
26
+ 'dreb',
27
+ 'pf',
28
+ 'plus_minus',
29
+ // NFL passing
30
+ 'passing_yards_per_game',
31
+ 'passing_completion_pct',
32
+ 'passing_first_down_pct',
33
+ 'yards_per_pass_attempt',
34
+ 'qbr',
35
+ 'passing_qbr',
36
+ 'passing_rating',
37
+ 'qb_rating',
38
+ // NFL rushing
39
+ 'rushing_yards_per_game',
40
+ 'rushing_average',
41
+ 'rushing_avg',
42
+ 'rushing_first_down_pct',
43
+ 'yards_per_rush_attempt',
44
+ // NFL receiving
45
+ 'receiving_yards_per_game',
46
+ 'receiving_average',
47
+ 'receiving_avg',
48
+ 'receiving_first_down_pct',
49
+ 'yards_per_reception',
50
+ // NFL returns / kicking / punting
51
+ 'yards_per_kick_return',
52
+ 'yards_per_punt_return',
53
+ 'field_goal_pct',
54
+ 'gross_avg_punt_yards',
55
+ // MLB
56
+ 'obp',
57
+ 'slg',
58
+ 'era',
59
+ 'fielding_pct',
60
+ 'batting_avg',
61
+ 'batting_obp',
62
+ 'batting_slg',
63
+ 'batting_ops',
64
+ 'pitching_era',
65
+ 'pitching_whip',
66
+ 'pitching_k_per_9',
67
+ // NHL
68
+ 'points_per_game',
69
+ 'shooting_pct',
70
+ 'faceoff_win_pct',
71
+ 'goals_against_average',
72
+ 'save_pct',
73
+ 'time_on_ice_per_game',
74
+ 'faceoff_winning_pctg',
75
+ 'save_pctg',
76
+ ];
77
+ const RAW_DECIMAL_KEYS = {
78
+ avg: 3,
79
+ obp: 3,
80
+ slg: 3,
81
+ batting_avg: 3,
82
+ batting_obp: 3,
83
+ batting_slg: 3,
84
+ batting_ops: 3,
85
+ fielding_pct: 3,
86
+ save_pct: 3,
87
+ save_pctg: 3,
88
+ era: 2,
89
+ pitching_era: 2,
90
+ pitching_whip: 2,
91
+ pitching_k_per_9: 2,
92
+ goals_against_average: 2,
93
+ points_per_game: 2,
94
+ };
95
+ const PERCENTAGE_KEYS = [
96
+ 'fg_pct',
97
+ 'fg3_pct',
98
+ 'ft_pct',
99
+ 'passing_completion_pct',
100
+ 'passing_first_down_pct',
101
+ 'rushing_first_down_pct',
102
+ 'receiving_first_down_pct',
103
+ 'field_goal_pct',
104
+ 'shooting_pct',
105
+ 'faceoff_win_pct',
106
+ 'faceoff_winning_pctg',
107
+ ];
108
+ const PLAYER_STAT_LABELS = {
109
+ min: 'MIN',
110
+ pts: 'PTS',
111
+ field_goals: 'FG',
112
+ fgm: 'FGM',
113
+ fga: 'FGA',
114
+ fg_pct: 'FG%',
115
+ three_pointers: '3PT',
116
+ fg3m: '3PM',
117
+ fg3a: '3PA',
118
+ fg3_pct: '3P%',
119
+ free_throws: 'FT',
120
+ ftm: 'FTM',
121
+ fta: 'FTA',
122
+ ft_pct: 'FT%',
123
+ reb: 'REB',
124
+ ast: 'AST',
125
+ turnover: 'TO',
126
+ stl: 'STL',
127
+ blk: 'BLK',
128
+ oreb: 'OREB',
129
+ dreb: 'DREB',
130
+ pf: 'PF',
131
+ plus_minus: '+/-',
132
+ games_played: 'GP',
133
+ completions_attempts: 'C/ATT',
134
+ passing_completions: 'CMP',
135
+ passing_attempts: 'ATT',
136
+ passing_yards: 'YDS',
137
+ passing_yards_per_game: 'YDS/G',
138
+ passing_completion_pct: 'CMP%',
139
+ passing_first_downs: '1D',
140
+ passing_first_down_pct: '1D%',
141
+ passing_20_plus_yards: '20+',
142
+ passing_40_plus_yards: '40+',
143
+ passing_long: 'LONG',
144
+ passing_sack_yards: 'YDS',
145
+ yards_per_pass_attempt: 'AVG',
146
+ passing_touchdowns: 'TD',
147
+ passing_interceptions: 'INT',
148
+ passing_sacks: 'SACKS',
149
+ sacks: 'SACKS',
150
+ sacks_loss: 'YDS',
151
+ qbr: 'QBR',
152
+ passing_qbr: 'QBR',
153
+ passing_rating: 'RTG',
154
+ qb_rating: 'RTG',
155
+ rushing_attempts: 'CAR',
156
+ rushing_yards: 'YDS',
157
+ rushing_yards_per_game: 'YDS/G',
158
+ rushing_average: 'AVG',
159
+ rushing_avg: 'AVG',
160
+ rushing_first_downs: '1D',
161
+ rushing_first_down_pct: '1D%',
162
+ rushing_20_plus_yards: '20+',
163
+ rushing_40_plus_yards: '40+',
164
+ rushing_fumbles: 'FUM',
165
+ yards_per_rush_attempt: 'AVG',
166
+ rushing_touchdowns: 'TD',
167
+ long_rushing: 'LONG',
168
+ rushing_long: 'LONG',
169
+ receptions: 'REC',
170
+ receiving_yards: 'YDS',
171
+ receiving_yards_per_game: 'YDS/G',
172
+ receiving_average: 'AVG',
173
+ receiving_avg: 'AVG',
174
+ receiving_first_downs: '1D',
175
+ receiving_first_down_pct: '1D%',
176
+ receiving_20_plus_yards: '20+',
177
+ receiving_40_plus_yards: '40+',
178
+ receiving_fumbles: 'FUM',
179
+ yards_per_reception: 'AVG',
180
+ receiving_touchdowns: 'TD',
181
+ long_reception: 'LONG',
182
+ receiving_long: 'LONG',
183
+ receiving_targets: 'TGTS',
184
+ fumbles: 'FUM',
185
+ fumbles_lost: 'LOST',
186
+ fumbles_forced: 'FF',
187
+ fumbles_recovered: 'REC',
188
+ total_tackles: 'TOT',
189
+ solo_tackles: 'SOLO',
190
+ defensive_sacks: 'SACKS',
191
+ tackles_for_loss: 'TFL',
192
+ passes_defended: 'PD',
193
+ qb_hits: 'QB HTS',
194
+ defensive_touchdowns: 'TD',
195
+ defensive_interceptions: 'INT',
196
+ interceptions: 'INT',
197
+ interception_yards: 'YDS',
198
+ interception_touchdowns: 'TD',
199
+ kick_returns: 'NO',
200
+ kick_return_yards: 'YDS',
201
+ yards_per_kick_return: 'AVG',
202
+ long_kick_return: 'LONG',
203
+ kick_return_touchdowns: 'TD',
204
+ punt_returns: 'NO',
205
+ punt_return_yards: 'YDS',
206
+ yards_per_punt_return: 'AVG',
207
+ long_punt_return: 'LONG',
208
+ punt_return_touchdowns: 'TD',
209
+ field_goal_pct: 'PCT',
210
+ field_goal_attempts: 'FGA',
211
+ field_goals_made: 'FGM',
212
+ long_field_goal_made: 'LONG',
213
+ extra_points_made: 'XP',
214
+ total_points: 'PTS',
215
+ punts: 'NO',
216
+ punt_yards: 'YDS',
217
+ gross_avg_punt_yards: 'AVG',
218
+ touchbacks: 'TB',
219
+ punts_inside_20: 'In 20',
220
+ long_punt: 'LONG',
221
+ hits_at_bats: 'H-AB',
222
+ at_bats: 'AB',
223
+ runs: 'R',
224
+ hits: 'H',
225
+ rbi: 'RBI',
226
+ hr: 'HR',
227
+ bb: 'BB',
228
+ k: 'K',
229
+ avg: 'AVG',
230
+ obp: 'OBP',
231
+ slg: 'SLG',
232
+ ip: 'IP',
233
+ p_hits: 'H',
234
+ p_runs: 'R',
235
+ er: 'ER',
236
+ p_bb: 'BB',
237
+ p_k: 'K',
238
+ p_hr: 'HR',
239
+ pitches_strikes: 'PC-ST',
240
+ era: 'ERA',
241
+ pitch_count: 'PC',
242
+ doubles: '2B',
243
+ triples: '3B',
244
+ intentional_walks: 'IBB',
245
+ hit_by_pitch: 'HBP',
246
+ stolen_bases: 'SB',
247
+ caught_stealing: 'CS',
248
+ plate_appearances: 'PA',
249
+ total_bases: 'TB',
250
+ left_on_base: 'LOB',
251
+ fly_outs: 'FO',
252
+ ground_outs: 'GO',
253
+ line_outs: 'LO',
254
+ pop_outs: 'PO',
255
+ air_outs: 'AO',
256
+ gidp: 'GIDP',
257
+ sac_bunts: 'SH',
258
+ sac_flies: 'SF',
259
+ strikes: 'ST',
260
+ batters_faced: 'BF',
261
+ pitching_outs: 'OUT',
262
+ wins: 'W',
263
+ losses: 'L',
264
+ holds: 'HLD',
265
+ blown_saves: 'BS',
266
+ games_started: 'GS',
267
+ wild_pitches: 'WP',
268
+ balks: 'BK',
269
+ pitching_hbp: 'HBP',
270
+ inherited_runners: 'IR',
271
+ inherited_runners_scored: 'IRS',
272
+ putouts: 'PO',
273
+ errors: 'E',
274
+ fielding_chances: 'TC',
275
+ fielding_pct: 'FPCT',
276
+ batting_gp: 'GP',
277
+ batting_ab: 'AB',
278
+ batting_r: 'R',
279
+ batting_h: 'H',
280
+ batting_avg: 'AVG',
281
+ batting_2b: '2B',
282
+ batting_3b: '3B',
283
+ batting_hr: 'HR',
284
+ batting_rbi: 'RBI',
285
+ batting_tb: 'TB',
286
+ batting_bb: 'BB',
287
+ batting_so: 'SO',
288
+ batting_sb: 'SB',
289
+ batting_obp: 'OBP',
290
+ batting_slg: 'SLG',
291
+ batting_ops: 'OPS',
292
+ batting_war: 'WAR',
293
+ pitching_gp: 'GP',
294
+ pitching_gs: 'GS',
295
+ pitching_qs: 'QS',
296
+ pitching_w: 'W',
297
+ pitching_l: 'L',
298
+ pitching_era: 'ERA',
299
+ pitching_sv: 'SV',
300
+ pitching_hld: 'HLD',
301
+ pitching_ip: 'IP',
302
+ pitching_h: 'H',
303
+ pitching_er: 'ER',
304
+ pitching_hr: 'HR',
305
+ pitching_bb: 'BB',
306
+ pitching_whip: 'WHIP',
307
+ pitching_k: 'K',
308
+ pitching_k_per_9: 'K/9',
309
+ pitching_war: 'WAR',
310
+ goals: 'G',
311
+ assists: 'A',
312
+ points: 'PTS',
313
+ points_per_game: 'PTS/G',
314
+ shots: 'S',
315
+ shooting_pct: 'S%',
316
+ even_strength_goals: 'EVG',
317
+ even_strength_points: 'EVP',
318
+ power_play_goals: 'PPG',
319
+ power_play_points: 'PPP',
320
+ short_handed_goals: 'SHG',
321
+ short_handed_points: 'SHP',
322
+ game_winning_goals: 'GWG',
323
+ overtime_goals: 'OTG',
324
+ faceoff_win_pct: 'FO%',
325
+ ot_losses: 'OTL',
326
+ shutouts: 'SO',
327
+ save_pct: 'SV%',
328
+ goals_against_average: 'GAA',
329
+ time_on_ice_per_game: 'TOI/G',
330
+ shots_on_goal: 'S',
331
+ blocked_shots: 'BS',
332
+ penalty_minutes: 'PIM',
333
+ takeaways: 'TK',
334
+ giveaways: 'GV',
335
+ shifts: 'SHFT',
336
+ time_on_ice: 'TOI',
337
+ faceoff_winning_pctg: 'FO%',
338
+ shots_against: 'SA',
339
+ goals_against: 'GA',
340
+ saves: 'SV',
341
+ save_pctg: 'SV%',
342
+ even_strength_saves: 'ESSV',
343
+ power_play_saves: 'PPSV',
344
+ shorthanded_saves: 'SHSV',
345
+ shots_on_target: 'SOG',
346
+ shots_total: 'SHOT',
347
+ passes_accurate: 'AC.PASS',
348
+ passes_total: 'PASS',
349
+ key_passes: 'KEY PASS',
350
+ ball_recoveries: 'REC',
351
+ minutes_played: 'MIN',
352
+ dribbles_completed: 'DRIB',
353
+ penalty_saves: 'PK SV',
354
+ clearances: 'CLR',
355
+ offsides: 'OF',
356
+ tackles_won: 'TKLW',
357
+ fouls_committed: 'FC',
358
+ fouls_suffered: 'FA',
359
+ };
360
+ const GAME_STAT_LABELS = {
361
+ passing_yards: 'PASS YDS',
362
+ rushing_yards: 'RUSH YDS',
363
+ receiving_yards: 'REC YDS',
364
+ kick_return_yards: 'KR YDS',
365
+ punt_return_yards: 'PR YDS',
366
+ };
367
+ const labelPlayerStat = (key) => PLAYER_STAT_LABELS[key] || key.replace(/_/g, ' ').toLowerCase();
368
+ exports.labelPlayerStat = labelPlayerStat;
369
+ const labelGameStat = (key) => GAME_STAT_LABELS[key] || (0, exports.labelPlayerStat)(key);
370
+ exports.labelGameStat = labelGameStat;
371
+ const formatPlayerStat = (key, value) => {
372
+ if (typeof value !== 'number')
373
+ return value;
374
+ const decimals = RAW_DECIMAL_KEYS[key];
375
+ if (decimals !== undefined) {
376
+ return value.toFixed(decimals);
377
+ }
378
+ if (PERCENTAGE_KEYS.includes(key)) {
379
+ return `${(value <= 1 ? value * 100 : value).toFixed(1)}%`;
380
+ }
381
+ return Number.isInteger(value) ? value.toLocaleString() : value.toFixed(1);
382
+ };
383
+ exports.formatPlayerStat = formatPlayerStat;
384
+ const getImportantPlayerStats = (stats, limit = 3) => Object.entries(stats)
385
+ .filter(([key]) => !['id', 'player_id', 'team_id', 'team_name'].includes(key))
386
+ .slice(0, limit);
387
+ exports.getImportantPlayerStats = getImportantPlayerStats;
388
+ const getPlayerGameStats = (stats, league, position) => {
389
+ if (!stats)
390
+ return undefined;
391
+ const positionCode = (position || '').toUpperCase();
392
+ const selected = {};
393
+ const add = (key, limit = 3, includeZero = false) => {
394
+ const value = stats[key];
395
+ if (Object.keys(selected).length < limit &&
396
+ ((typeof value === 'number' && (includeZero || value !== 0)) ||
397
+ (typeof value === 'string' &&
398
+ value.length > 0 &&
399
+ value !== '0' &&
400
+ value !== '00:00'))) {
401
+ selected[key] = value;
402
+ }
403
+ };
404
+ const addFrom = (keys, limit = 3) => {
405
+ keys.forEach((key) => add(key, limit));
406
+ };
407
+ if (league === 'mlb') {
408
+ if (positionCode.includes('PITCH') || ['P', 'SP', 'RP'].includes(positionCode)) {
409
+ if (typeof stats.ip === 'number' && stats.ip > 0) {
410
+ add('ip');
411
+ if (positionCode === 'SP') {
412
+ add('p_hits', 4, true);
413
+ add('er', 4, true);
414
+ add('p_k', 4, true);
415
+ addFrom(['p_bb', 'p_hr', 'pitch_count']);
416
+ }
417
+ else {
418
+ addFrom(['p_k', 'saves', 'holds', 'p_hits', 'p_bb']);
419
+ add('er', 3, true);
420
+ }
421
+ }
422
+ else {
423
+ addFrom(['saves', 'holds', 'p_k', 'p_hits', 'p_bb']);
424
+ }
425
+ }
426
+ else {
427
+ if (typeof stats.hits === 'number' &&
428
+ typeof stats.at_bats === 'number' &&
429
+ stats.at_bats > 0) {
430
+ selected.hits_at_bats = `${stats.hits}-${stats.at_bats}`;
431
+ }
432
+ addFrom([
433
+ 'hr',
434
+ 'triples',
435
+ 'doubles',
436
+ 'rbi',
437
+ 'runs',
438
+ 'bb',
439
+ 'stolen_bases',
440
+ 'k',
441
+ ]);
442
+ }
443
+ }
444
+ else if (['nba', 'wnba', 'cbb', 'ncaa'].includes(league)) {
445
+ addFrom(['pts', 'reb', 'ast', 'stl', 'blk', 'fg3m', 'min']);
446
+ }
447
+ else if (league === 'nfl' || league === 'cfb') {
448
+ if (positionCode.includes('QB') || positionCode.includes('QUARTER')) {
449
+ if (typeof stats.passing_completions === 'number' &&
450
+ typeof stats.passing_attempts === 'number' &&
451
+ stats.passing_attempts > 0) {
452
+ selected.completions_attempts =
453
+ `${stats.passing_completions}/${stats.passing_attempts}`;
454
+ add('passing_yards', 4, true);
455
+ add('passing_touchdowns', 4, true);
456
+ add('passing_interceptions', 4, true);
457
+ }
458
+ else {
459
+ addFrom([
460
+ 'passing_yards',
461
+ 'passing_touchdowns',
462
+ 'passing_interceptions',
463
+ 'rushing_yards',
464
+ ]);
465
+ }
466
+ }
467
+ else if (positionCode.includes('RB') || positionCode.includes('RUNNING')) {
468
+ addFrom([
469
+ 'rushing_yards',
470
+ 'rushing_touchdowns',
471
+ 'receptions',
472
+ 'receiving_touchdowns',
473
+ 'rushing_attempts',
474
+ 'receiving_yards',
475
+ ]);
476
+ }
477
+ else if (positionCode.includes('WR') ||
478
+ positionCode.includes('TE') ||
479
+ positionCode.includes('RECEIV')) {
480
+ addFrom([
481
+ 'receptions',
482
+ 'receiving_yards',
483
+ 'receiving_touchdowns',
484
+ 'receiving_targets',
485
+ 'rushing_yards',
486
+ ]);
487
+ }
488
+ else if (['PK', 'K'].includes(positionCode)) {
489
+ if (typeof stats.field_goal_attempts === 'number' &&
490
+ stats.field_goal_attempts > 0 &&
491
+ typeof stats.field_goals_made === 'number') {
492
+ selected.field_goals =
493
+ `${stats.field_goals_made}/${stats.field_goal_attempts}`;
494
+ }
495
+ addFrom([
496
+ 'extra_points_made',
497
+ 'total_points',
498
+ 'long_field_goal_made',
499
+ ]);
500
+ }
501
+ else if (positionCode === 'P') {
502
+ addFrom([
503
+ 'punts',
504
+ 'gross_avg_punt_yards',
505
+ 'punts_inside_20',
506
+ 'punt_yards',
507
+ ]);
508
+ }
509
+ else if (['KR', 'PR'].includes(positionCode) &&
510
+ (stats.kick_returns || stats.punt_returns)) {
511
+ addFrom([
512
+ 'kick_return_touchdowns',
513
+ 'punt_return_touchdowns',
514
+ 'kick_return_yards',
515
+ 'punt_return_yards',
516
+ 'kick_returns',
517
+ 'punt_returns',
518
+ ]);
519
+ }
520
+ addFrom([
521
+ 'total_tackles',
522
+ 'defensive_sacks',
523
+ 'defensive_interceptions',
524
+ 'passes_defended',
525
+ 'tackles_for_loss',
526
+ 'qb_hits',
527
+ 'solo_tackles',
528
+ ]);
529
+ addFrom([
530
+ 'rushing_yards',
531
+ 'receptions',
532
+ 'receiving_yards',
533
+ 'kick_return_yards',
534
+ 'punt_return_yards',
535
+ ]);
536
+ }
537
+ else if (league === 'nhl') {
538
+ if (positionCode === 'G' || positionCode.includes('GOAL')) {
539
+ add('saves');
540
+ add('shots_against');
541
+ if (Object.keys(selected).length > 0)
542
+ add('goals_against', 3, true);
543
+ add('time_on_ice');
544
+ }
545
+ else {
546
+ add('goals');
547
+ add('assists');
548
+ addFrom(positionCode === 'D'
549
+ ? ['blocked_shots', 'shots_on_goal', 'hits']
550
+ : ['shots_on_goal', 'hits', 'blocked_shots']);
551
+ if (!selected.goals && !selected.assists)
552
+ add('points');
553
+ add('time_on_ice');
554
+ }
555
+ }
556
+ else if ((0, soccerLeagues_1.isSoccerLeague)(league)) {
557
+ if (positionCode === 'G' || positionCode === 'GK') {
558
+ if (typeof stats.saves === 'number' && stats.saves > 0) {
559
+ add('saves');
560
+ }
561
+ else if (typeof stats.goalkeeper_saves === 'number' &&
562
+ stats.goalkeeper_saves > 0) {
563
+ selected.saves = stats.goalkeeper_saves;
564
+ }
565
+ addFrom([
566
+ 'penalty_saves',
567
+ 'clearances',
568
+ 'ball_recoveries',
569
+ ]);
570
+ }
571
+ else {
572
+ add('goals');
573
+ add('assists');
574
+ addFrom(positionCode === 'D'
575
+ ? [
576
+ 'tackles_won',
577
+ 'interceptions',
578
+ 'clearances',
579
+ 'ball_recoveries',
580
+ ]
581
+ : positionCode === 'M'
582
+ ? [
583
+ 'key_passes',
584
+ 'tackles_won',
585
+ 'shots_on_target',
586
+ ]
587
+ : [
588
+ 'shots_on_target',
589
+ 'shots_total',
590
+ 'key_passes',
591
+ 'dribbles_completed',
592
+ ]);
593
+ }
594
+ if (Object.keys(selected).length < 3 &&
595
+ typeof stats.passes_accurate === 'number' &&
596
+ typeof stats.passes_total === 'number' &&
597
+ stats.passes_total > 0) {
598
+ selected.passes_total =
599
+ `${stats.passes_accurate}/${stats.passes_total}`;
600
+ }
601
+ add('minutes_played');
602
+ }
603
+ return Object.keys(selected).length ? selected : undefined;
604
+ };
605
+ exports.getPlayerGameStats = getPlayerGameStats;
606
+ const getGameLogPlayerStats = (stats, league, position) => {
607
+ var _a;
608
+ return Object.entries((_a = (0, exports.getPlayerGameStats)(stats, league, position)) !== null && _a !== void 0 ? _a : {}).map(([key, value]) => ({ key, label: (0, exports.labelGameStat)(key), value }));
609
+ };
610
+ exports.getGameLogPlayerStats = getGameLogPlayerStats;
611
+ const getCareerPlayerStats = (seasons, keys) => Object.fromEntries(keys.map(key => {
612
+ const values = seasons
613
+ .map(season => season.stats[key])
614
+ .filter((value) => typeof value === 'number');
615
+ if (values.length === 0)
616
+ return [key, '—'];
617
+ const total = values.reduce((sum, value) => sum + value, 0);
618
+ const isAverage = CAREER_AVERAGE_KEYS.some(part => key.includes(part));
619
+ return [key, isAverage ? total / values.length : total];
620
+ }));
621
+ exports.getCareerPlayerStats = getCareerPlayerStats;
622
+ const formatGameStats = (stats) => Object.entries(stats !== null && stats !== void 0 ? stats : {})
623
+ .map(([key, value]) => `${(0, exports.formatPlayerStat)(key, value)} ${(0, exports.labelGameStat)(key)}`)
624
+ .join(' • ');
625
+ exports.formatGameStats = formatGameStats;
626
+ const formatGameLogStats = (stats, league, position) => (0, exports.formatGameStats)((0, exports.getPlayerGameStats)(stats, league, position));
627
+ exports.formatGameLogStats = formatGameLogStats;
package/dist/index.d.ts CHANGED
@@ -69,3 +69,4 @@ export * from "./models/standings";
69
69
  export * from "./models/attendance";
70
70
  export * from "./models/miniLeague";
71
71
  export * from "./constants";
72
+ export * from "./helpers/playerProfileFormat";
package/dist/index.js CHANGED
@@ -85,3 +85,4 @@ __exportStar(require("./models/standings"), exports);
85
85
  __exportStar(require("./models/attendance"), exports);
86
86
  __exportStar(require("./models/miniLeague"), exports);
87
87
  __exportStar(require("./constants"), exports);
88
+ __exportStar(require("./helpers/playerProfileFormat"), exports);
@@ -1,7 +1,9 @@
1
1
  import { z } from "zod";
2
2
  import { basketballGameSchema, broadcastSchema, cfbGameSchema, commonGameSchema, creatorPickSchema, footballGameSchema, gameRatingAggregateSchema, gameSchema, gameTeamSchema, groupedRatingAggregateSchema, mlbGameSchema, nflGameSchema, nhlGameSchema, overviewSchema, ratingTagCountSchema, ratingTagCountsSchema, searchGameSchema, unionGameSchema, weightedRatingAggregateOptionsSchema, weightedRatingAggregateSchema } from "../schemas/game";
3
3
  import { sportType } from "../schemas/sharedTypes";
4
+ import { pollGameSchema } from "../schemas/game";
4
5
  export type Game = z.infer<typeof gameSchema>;
6
+ export type PollGame = z.infer<typeof pollGameSchema>;
5
7
  export type BasketballGame = z.infer<typeof basketballGameSchema>;
6
8
  export type MLBGame = z.infer<typeof mlbGameSchema>;
7
9
  export type GameRatingAggregate = z.infer<typeof gameRatingAggregateSchema>;