From 3e3b71d2308fa36ea2f4a3f98f57f76c0d8a7c46 Mon Sep 17 00:00:00 2001
From: Alexander Rose <alex.rose@rcsb.org>
Date: Thu, 19 Sep 2019 17:08:36 -0700
Subject: [PATCH] added Interval.ofLength

---
 src/mol-data/int/impl/interval.ts | 1 +
 src/mol-data/int/interval.ts      | 2 ++
 2 files changed, 3 insertions(+)

diff --git a/src/mol-data/int/impl/interval.ts b/src/mol-data/int/impl/interval.ts
index a1097c13f..29307c74b 100644
--- a/src/mol-data/int/impl/interval.ts
+++ b/src/mol-data/int/impl/interval.ts
@@ -9,6 +9,7 @@ import Tuple from '../tuple'
 export const Empty = Tuple.Zero;
 export function ofRange(min: number, max: number) { return max < min ? Tuple.create(min, min) : Tuple.create(min, max + 1); }
 export function ofBounds(start: number, end: number) { return end <= start ? Tuple.create(start, start) : Tuple.create(start, end); }
+export function ofLength(length: number) { return length < 0 ? Tuple.create(0, 0) : Tuple.create(0, length); }
 export const is = Tuple.is;
 
 export const start = Tuple.fst;
diff --git a/src/mol-data/int/interval.ts b/src/mol-data/int/interval.ts
index a192dbccc..ea8e9c18e 100644
--- a/src/mol-data/int/interval.ts
+++ b/src/mol-data/int/interval.ts
@@ -14,6 +14,8 @@ namespace Interval {
     export const ofRange: <T extends number = number>(min: T, max: T) => Interval<T> = Impl.ofRange as any;
     /** Create interval from bounds [start, end), i.e. [start, end - 1] */
     export const ofBounds: <T extends number = number>(start: T, end: T) => Interval<T> = Impl.ofBounds as any;
+    /** Create interval from length [0, length), i.e. [0, length - 1] */
+    export const ofLength: <T extends number = number>(length: T) => Interval<T> = Impl.ofLength as any;
     export const is: <T extends number = number>(v: any) => v is Interval<T> = Impl.is as any;
 
     /** Test if a value is within the bounds of the interval */
-- 
GitLab