Spaces:
Running
Running
Download forecast-utils.js from Banaxi-Tech/Release-Estimator: direct link, hf CLI and curl.
- Browser
- Download file 986 Bytes
-
https://huggingface.co/spaces/Banaxi-Tech/Release-Estimator/resolve/main/forecast-utils.js
- Command line
-
hf download hf://spaces/Banaxi-Tech/Release-Estimator/forecast-utils.js
-
curl -L -o forecast-utils.js https://huggingface.co/spaces/Banaxi-Tech/Release-Estimator/resolve/main/forecast-utils.js
986 Bytes
| export function dateLabel(date) { | |
| return new Intl.DateTimeFormat('en-US', {month:'long',day:'numeric',timeZone:'UTC'}).format(new Date(`${date}T12:00:00Z`)); | |
| } | |
| export function outcomes(model, mode, finalDate) { | |
| const rows=model[mode].map(row=>({...row,label:row.date==='later'?`No release by ${dateLabel(finalDate)}`:`${mode==='by'?'By ':''}${dateLabel(row.date)}`})); | |
| if(mode==='by') rows.push({date:'later',chance:Math.round((100-model.by.at(-1).chance)*10)/10,label:`No release by ${dateLabel(finalDate)}`}); | |
| return rows; | |
| } | |
| export function topFive(model,mode,finalDate) {return outcomes(model,mode,finalDate).sort((a,b)=>b.chance-a.chance).slice(0,5)} | |
| export function validateChances(rows,mode) { | |
| if(rows.some(r=>!Number.isFinite(r.chance)||r.chance<0||r.chance>100))return 'Every chance must be a number between 0 and 100.'; | |
| if(mode==='by'&&rows.some((r,i)=>i>0&&r.chance<rows[i-1].chance))return 'Later deadlines must have the same or a higher chance.'; | |
| return ''; | |
| } | |