MCPcopy Create free account
hub / github.com/freeCodeCamp/freeCodeCamp / filterBySuperblock

Function filterBySuperblock

curriculum/src/filter.ts:36–48  ·  view source on GitHub ↗
(
  superblocks: T[],
  { superBlock }: { superBlock?: string } = {}
)

Source from the content-addressed store, hash-verified

34 * @returns {Array<Object>} Filtered array of superblocks containing only the specified superblock(s), or the original array if superBlock is not provided.
35 */
36export 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)

Callers 1

filter.test.jsFile · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected