Spaces:
Paused
Paused
Download console/src/features/files-workspace/profileFileSelection.ts from mysticaldragon/HF: direct link, hf CLI and curl.
- Browser
- Download file 879 Bytes
-
https://huggingface.co/spaces/mysticaldragon/HF/resolve/main/console/src/features/files-workspace/profileFileSelection.ts
- Command line
-
hf download hf://spaces/mysticaldragon/HF/console/src/features/files-workspace/profileFileSelection.ts
-
curl -L -o profileFileSelection.ts https://huggingface.co/spaces/mysticaldragon/HF/resolve/main/console/src/features/files-workspace/profileFileSelection.ts
879 Bytes
| import { isDefaultWorkspaceMarkdown } from "./defaultWorkspaceMarkdown"; | |
| import type { DirectoryEntry } from "./types"; | |
| export function selectProfileFiles( | |
| files: readonly DirectoryEntry[], | |
| enabledFiles: readonly string[], | |
| ): DirectoryEntry[] { | |
| const enabledOrder = new Map( | |
| enabledFiles.map((filename, index) => [filename, index]), | |
| ); | |
| return files | |
| .filter( | |
| (file) => | |
| isDefaultWorkspaceMarkdown(file.path) || enabledOrder.has(file.path), | |
| ) | |
| .sort((left, right) => { | |
| const leftIndex = enabledOrder.get(left.path); | |
| const rightIndex = enabledOrder.get(right.path); | |
| if (leftIndex !== undefined && rightIndex !== undefined) { | |
| return leftIndex - rightIndex; | |
| } | |
| if (leftIndex !== undefined) return -1; | |
| if (rightIndex !== undefined) return 1; | |
| return left.name.localeCompare(right.name); | |
| }); | |
| } | |