wcif-helpers
Version:
Some helpers for WCIF
3 lines (2 loc) • 1.79 kB
JavaScript
;const t=(t,e)=>e.events.find((e=>e.id===t)),e=(e,o)=>{const n=r(e),i=t(n,o);return null==i?void 0:i.rounds.find((t=>t.id===e))},r=t=>t.split("-")[0];exports.getActivityInfoFromSchedule=(t,e)=>{let r=null;return e.schedule.venues.forEach((e=>{e.rooms.forEach((e=>{e.activities.forEach((e=>{e.activityCode===t&&(r=e),e.childActivities.forEach((e=>{e.activityCode===t&&(r=e)}))}))}))})),r},exports.getActivityInfoFromScheduleWithRoom=(t,e,r)=>{let o=null;return r.schedule.venues.forEach((r=>{const n=r.rooms.find((t=>t.name===e));n&&n.activities.forEach((e=>{e.activityCode===t&&(o=e),e.childActivities.forEach((e=>{e.activityCode===t&&(o=e)}))}))})),o},exports.getCompetitionDates=(t,e)=>{const r=[];for(let o=0;o<e;o++)r.push(new Date(t)),t.setDate(t.getDate()+1);return r},exports.getCutoffByRoundId=(t,r)=>{const o=e(t,r);return(null==o?void 0:o.cutoff)||null},exports.getEventIdFromRoundId=r,exports.getEventInfoFromWcif=t,exports.getGroupInfoByActivityId=(t,e)=>{let r=null;return e.schedule.venues.forEach((e=>{e.rooms.forEach((e=>{e.activities.forEach((e=>{e.id===t&&(r=e),e.childActivities.forEach((e=>{e.id===t&&(r=e)}))}))}))})),r},exports.getLimitByRoundId=(t,r)=>{const o=e(t,r);return(null==o?void 0:o.timeLimit)||null},exports.getNumberOfAttemptsForRound=(t,r)=>{const o=e(t,r);if(!o)return 0;switch(o.format){case"1":return 1;case"2":return 2;case"3":case"m":return 3;case"a":return 5}},exports.getPersonFromWcif=(t,e)=>e.persons.find((e=>e.registrantId===t)),exports.getRoundInfoFromWcif=e,exports.prettyRoundFormat=(t,e)=>{switch(t){case"1":return"Best of 1";case"2":return"Best of 2";case"3":return"Best of 3";case"a":return e?`Best of ${e} / Average of 5`:"Average of 5";case"m":return"Mean of 3";default:return"Unknown"}};
//# sourceMappingURL=index.js.map