(foundChallenges: Challenge[], meta: Meta)
| 121 | * @returns {object} Block object with ordered challenges |
| 122 | */ |
| 123 | export function buildBlock(foundChallenges: Challenge[], meta: Meta) { |
| 124 | const challenges = meta.challengeOrder.map(challengeInfo => { |
| 125 | const challenge = foundChallenges.find(c => c.id === challengeInfo.id); |
| 126 | if (!challenge) { |
| 127 | throw Error( |
| 128 | `Challenge ${challengeInfo.id} (${challengeInfo.title}) not found in block` |
| 129 | ); |
| 130 | } |
| 131 | |
| 132 | return challenge; |
| 133 | }); |
| 134 | |
| 135 | return { |
| 136 | challenges, |
| 137 | meta |
| 138 | }; |
| 139 | } |
| 140 | |
| 141 | /** |
| 142 | * Adds the meta information to a challenge |
no outgoing calls
no test coverage detected