quiz_flash / src /lib /exampleUtils.ts
Hoooong's picture
Small refactor
b0768ab
raw
history blame contribute delete
588 Bytes
import type { PromptExample } from '@/types/example';
/**
* Get all unique sub-types from a collection of examples
*/
export function getUniqueSubTypes(examples: PromptExample[]): string[] {
const subTypes = new Set<string>();
examples.forEach(example => {
if (example.ε­ι‘Œεž‹) {
subTypes.add(example.ε­ι‘Œεž‹);
}
});
return Array.from(subTypes);
}
/**
* Filter examples by sub-type
*/
export function getExamplesBySubType(examples: PromptExample[], subType: string): PromptExample[] {
return examples.filter(example => example.ε­ι‘Œεž‹ === subType);
}