microsoft/qdk
Publicmirrored fromhttps://github.com/microsoft/qdkAvailable
source/npm/qsharp/src/katas-md.ts
28lines · modecode
| 1 | // Copyright (c) Microsoft Corporation. |
| 2 | // Licensed under the MIT License. |
| 3 | |
| 4 | // IMPORTANT: This file is kept stand-alone from the general katas.ts so |
| 5 | // that the Markdown version of the bundle is not pulled into any packages |
| 6 | // when not needed, thus reducing bundle sizes for the production site. |
| 7 | |
| 8 | import { default as katasContent } from "./katas-content.generated.md.js"; |
| 9 | |
| 10 | import type { Kata, Exercise } from "./katas.js"; |
| 11 | |
| 12 | export async function getAllKatas( |
| 13 | options: { includeUnpublished?: boolean } = { includeUnpublished: false }, |
| 14 | ): Promise<Kata[]> { |
| 15 | return katasContent.katas.filter( |
| 16 | (k) => options.includeUnpublished || k.published, |
| 17 | ) as Kata[]; |
| 18 | } |
| 19 | |
| 20 | export async function getExerciseSources( |
| 21 | exercise: Exercise, |
| 22 | ): Promise<string[]> { |
| 23 | return katasContent.globalCodeSources |
| 24 | .filter((source) => exercise.sourceIds.indexOf(source.id) > -1) |
| 25 | .map((source) => source.code); |
| 26 | } |
| 27 | |
| 28 | export type { Exercise, Kata }; |
| 29 | |