MCPcopy Index your code
hub / github.com/freeCodeCamp/freeCodeCamp / normalizeChallenges

Function normalizeChallenges

api/src/utils/normalize.ts:181–203  ·  view source on GitHub ↗
(
  completedChallenges: CompletedChallenge[]
)

Source from the content-addressed store, hash-verified

179 * @returns The input with nulls removed.
180 */
181export const normalizeChallenges = (
182 completedChallenges: CompletedChallenge[]
183): NormalizedChallenge[] => {
184 const fixedDateAndType = completedChallenges.map(challenge => {
185 const { completedDate, challengeType, ...rest } = challenge;
186 return {
187 ...rest,
188 completedDate: normalizeDate(completedDate),
189 challengeType: normalizeChallengeType(challengeType)
190 };
191 });
192
193 const noNullProps = fixedDateAndType.map(challenge => removeNulls(challenge));
194 // files.path is optional
195 const noNullPath = noNullProps.map(challenge => {
196 const { files, ...rest } = challenge;
197 const noNullFiles = files?.map(file => removeNulls(file));
198
199 return { ...rest, files: noNullFiles };
200 });
201
202 return noNullPath;
203};
204
205type NormalizedSurvey = {
206 title: string;

Callers 5

normalize.test.tsFile · 0.85
userPublicGetRoutesFunction · 0.85
deleteResetModuleFunction · 0.85
getSessionUserHandlerFunction · 0.85

Calls 3

normalizeDateFunction · 0.85
normalizeChallengeTypeFunction · 0.85
removeNullsFunction · 0.85

Tested by

no test coverage detected