Skip to main content

Variable: cricketMatchState

const cricketMatchState: (summary, opts) => CricketState[] = cricket_match_state

Defined in: src/models/cricket_wp.ts:365

camelCase alias of cricket_match_state.

Extract over-level match state from an ESPN cricket summary / scoreboard-event payload (py cricket_match_state): one row per competitor with a parseable score string.

Parameters​

summary​

any

An ESPN cricket summary payload or one scoreboard.events[i] object. The competition is read from header.competitions[0], else competitions[0]; the event id from competition.id, summary.id, then summary.header.id. A non-object yields no rows.

opts​

fmt: the format slug for every row ('t20' / 'odi', see get_format).

fmt​

string

Returns​

CricketState[]

CricketState rows sorted by innings_number (stable: Array#sort), innings 2 iff the score string carries a target. Competitors without a parseable score are skipped.

Throws​

Error From get_format, for fmt 'test' (deferred) or an unknown slug.

Remarks​

Pure: no network. balls_total is the format's, not read from the payload.

Example​

import sdv from 'sportsdataverse';
const sb = await sdv.cricket.espnCricketScoreboard({ league: '8048' }); // IPL, raw payload
const state = sdv.cricket.cricket_match_state(sb.events[0], { fmt: 't20' });