| 34 | * @returns {Array<Object>} Filtered array of superblocks containing only the specified superblock(s), or the original array if superBlock is not provided. |
| 35 | */ |
| 36 | export function filterBySuperblock<T extends { name: string }>( |
| 37 | superblocks: T[], |
| 38 | { superBlock }: { superBlock?: string } = {} |
| 39 | ): T[] { |
| 40 | if (!superBlock) return superblocks; |
| 41 | |
| 42 | const superBlockList = superBlock |
| 43 | .split(',') |
| 44 | .map(s => s.trim()) |
| 45 | .filter(s => s.length > 0); |
| 46 | |
| 47 | return superblocks.filter(({ name }) => superBlockList.includes(name)); |
| 48 | } |
| 49 | |
| 50 | /** |
| 51 | * Filters challenges in superblocks to only include those matching the given challenge id and their solution challenges (i.e. the next challenge, if it exists) |