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