diff options
Diffstat (limited to 'viewer/src/services/itemGuards.ts')
-rw-r--r-- | viewer/src/services/itemGuards.ts | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/viewer/src/services/itemGuards.ts b/viewer/src/services/itemGuards.ts new file mode 100644 index 0000000..114c2d9 --- /dev/null +++ b/viewer/src/services/itemGuards.ts | |||
@@ -0,0 +1,11 @@ | |||
1 | import { DirectoryItem, DownloadableItem, Item } from '@/@types/gallery'; | ||
2 | import { ItemType } from '@/@types/itemType'; | ||
3 | |||
4 | export function isDirectory(item: Item | null): item is DirectoryItem { | ||
5 | return item?.properties.type === ItemType.DIRECTORY; | ||
6 | } | ||
7 | |||
8 | export function isDownloadableItem(item: Item | null): item is DownloadableItem { | ||
9 | if (!item?.properties) return false; | ||
10 | return 'resource' in item.properties; | ||
11 | } | ||