aboutsummaryrefslogtreecommitdiff
path: root/viewer/src/services/itemGuards.ts
blob: 114c2d93c6679b8fe1d30fb3c23cc45330593825 (plain)
1
2
3
4
5
6
7
8
9
10
11
import { DirectoryItem, DownloadableItem, Item } from '@/@types/gallery';
import { ItemType } from '@/@types/itemType';

export function isDirectory(item: Item | null): item is DirectoryItem {
  return item?.properties.type === ItemType.DIRECTORY;
}

export function isDownloadableItem(item: Item | null): item is DownloadableItem {
  if (!item?.properties) return false;
  return 'resource' in item.properties;
}