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 { ...@@ -14,4 +14,17 @@ export function isNullLocation(x: any): x is NullLocation {
return !!x && x.kind === 'null-location'; return !!x && x.kind === 'null-location';
} }
export type Location = StructureElement | Link.Location | NullLocation /** A custom Location */
\ No newline at end of file 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 @@ ...@@ -6,6 +6,7 @@
import { StructureElement } from './structure' import { StructureElement } from './structure'
import { Link } from './structure/structure/unit/links' import { Link } from './structure/structure/unit/links'
import { CustomLocation } from './location';
/** A Loci that includes every loci */ /** A Loci that includes every loci */
export const EveryLoci = { kind: 'every-loci' as 'every-loci' } export const EveryLoci = { kind: 'every-loci' as 'every-loci' }
...@@ -21,4 +22,16 @@ export function isEmptyLoci(x: any): x is EmptyLoci { ...@@ -21,4 +22,16 @@ export function isEmptyLoci(x: any): x is EmptyLoci {
return !!x && x.kind === 'empty-loci'; return !!x && x.kind === 'empty-loci';
} }
export type Loci = StructureElement.Loci | Link.Loci | EveryLoci | EmptyLoci /** A Loci of custom locations */
\ No newline at end of file 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 { ...@@ -36,6 +36,8 @@ export function labelFirst(loci: Loci): string {
} else { } else {
return 'Unknown' return 'Unknown'
} }
case 'custom-loci':
return 'Custom'
case 'every-loci': case 'every-loci':
return 'Everything' return 'Everything'
case 'empty-loci': case 'empty-loci':
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment