( ids: string[], weights?: number[], groups?: string[], )
| 165 | * Mismatched-length arrays are tolerated (missing entries fall back to defaults). |
| 166 | */ |
| 167 | export function toWorkItems( |
| 168 | ids: string[], |
| 169 | weights?: number[], |
| 170 | groups?: string[], |
| 171 | ): WorkItem<string>[] { |
| 172 | return ids.map((id, i) => { |
| 173 | const item: WorkItem<string> = { id, payload: id }; |
| 174 | const w = weights?.[i]; |
| 175 | if (typeof w === 'number') item.weight = w; |
| 176 | const g = groups?.[i]; |
| 177 | if (typeof g === 'string' && g.length > 0) item.coupledKey = g; |
| 178 | return item; |
| 179 | }); |
| 180 | } |
no outgoing calls
no test coverage detected