Skip to content
Snippets Groups Projects
Commit 3e07b95c authored by Alexander Rose's avatar Alexander Rose
Browse files

wip, custom Loci and Location

parent cc07b6a9
No related branches found
No related tags found
No related merge requests found
......@@ -14,4 +14,17 @@ export function isNullLocation(x: any): x is NullLocation {
return !!x && x.kind === 'null-location';
}
export type Location = StructureElement | Link.Location | NullLocation
\ No newline at end of file
/** A custom Location */
export interface CustomLocation<D = any, K = any> {
readonly kind: 'custom-location'
data: D
key: K
}
export function CustomLocation<D, K>(data: D, key: K): CustomLocation<D, K> {
return { kind: 'custom-location', data, key }
}
export function isCustomLocation(x: any): x is CustomLocation<any, any> {
return !!x && x.kind === 'custom-location';
}
export type Location = StructureElement | Link.Location | NullLocation | CustomLocation
\ No newline at end of file
......@@ -6,6 +6,7 @@
import { StructureElement } from './structure'
import { Link } from './structure/structure/unit/links'
import { CustomLocation } from './location';
/** A Loci that includes every loci */
export const EveryLoci = { kind: 'every-loci' as 'every-loci' }
......@@ -21,4 +22,16 @@ export function isEmptyLoci(x: any): x is EmptyLoci {
return !!x && x.kind === 'empty-loci';
}
export type Loci = StructureElement.Loci | Link.Loci | EveryLoci | EmptyLoci
\ No newline at end of file
/** A Loci of custom locations */
export interface CustomLoci<D = any, K = any> {
readonly kind: 'custom-loci'
readonly locations: ReadonlyArray<CustomLocation>
}
export function CustomLoci<D, K>(locations: CustomLocation<D, K>[]): CustomLoci<D, K> {
return { kind: 'custom-loci', locations }
}
export function isCustomLoci(x: any): x is CustomLoci {
return !!x && x.kind === 'custom-loci';
}
export type Loci = StructureElement.Loci | Link.Loci | EveryLoci | EmptyLoci | CustomLoci
\ No newline at end of file
......@@ -36,6 +36,8 @@ export function labelFirst(loci: Loci): string {
} else {
return 'Unknown'
}
case 'custom-loci':
return 'Custom'
case 'every-loci':
return 'Everything'
case 'empty-loci':
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment