forked from QuantStack/jupyter-ai-tutor
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutils.ts
More file actions
39 lines (35 loc) · 889 Bytes
/
Copy pathutils.ts
File metadata and controls
39 lines (35 loc) · 889 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
export function isContinuous(numbers: number[]): boolean {
if (numbers.length <= 1) {
return true;
}
for (let i = 1; i < numbers.length; i++) {
if (numbers[i] !== numbers[i - 1] + 1) {
return false;
}
}
return true;
}
/**
* Decodes a ROT13 encoded string.
*/
export function decodeRot13(str: string): string {
return str.replace(/[a-zA-Z]/g, c => {
const base = c <= 'Z' ? 65 : 97;
return String.fromCharCode(((c.charCodeAt(0) - base + 13) % 26) + base);
});
}
export function formatEvaluationCriteria(criteriaData: unknown): string {
if (!criteriaData) {
return '';
}
if (typeof criteriaData === 'string') {
return criteriaData;
}
if (Array.isArray(criteriaData)) {
return criteriaData
.map(item => (typeof item === 'string' ? `- ${item.trim()}` : ''))
.filter(Boolean)
.join('\n');
}
return '';
}