@teselagen/range-utils 0.3.14-beta.1 → 0.3.14-beta.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/RangeAngles.d.ts +7 -0
- package/adjustRangeToDeletionOfAnotherRange.d.ts +2 -1
- package/adjustRangeToInsert.d.ts +2 -1
- package/adjustRangeToRotation.d.ts +5 -1
- package/checkIfNonCircularRangesOverlap.d.ts +2 -1
- package/checkIfPotentiallyCircularRangesOverlap.d.ts +2 -1
- package/collapseOverlapsGeneratedFromRangeComparisonIfPossible.d.ts +2 -1
- package/convertRangeIndices.d.ts +10 -1
- package/convertRangeTo0Based.d.ts +5 -1
- package/convertRangeTo1Based.d.ts +5 -1
- package/doesRangeSpanEntireSequence.d.ts +2 -1
- package/doesRangeSpanOrigin.d.ts +2 -1
- package/expandOrContractCircularRangeToPosition.d.ts +3 -2
- package/expandOrContractNonCircularRangeToPosition.d.ts +3 -2
- package/expandOrContractRangeByLength.d.ts +5 -1
- package/expandOrContractRangeToPosition.d.ts +3 -2
- package/flipContainedRange.d.ts +5 -1
- package/generateRandomRange.d.ts +3 -3
- package/getAnnotationRangeType.d.ts +2 -1
- package/getEachPositionInRangeAsArray.d.ts +2 -1
- package/getLengthOfOverlappingRegionsBetweenTwoRanges.d.ts +2 -1
- package/getMiddleOfRange.d.ts +2 -1
- package/getOverlapOfNonCircularRanges.d.ts +5 -4
- package/getOverlapsOfPotentiallyCircularRanges.d.ts +2 -1
- package/getPositionFromAngle.d.ts +1 -1
- package/getRangeAngles.d.ts +3 -7
- package/getRangeLength.d.ts +5 -1
- package/getRangesBetweenTwoRanges.d.ts +2 -1
- package/getSequenceWithinRange.d.ts +2 -1
- package/getShortestDistanceBetweenTwoPositions.d.ts +1 -1
- package/getYOffsetForPotentiallyCircularRange.d.ts +2 -1
- package/getYOffsetsForPotentiallyCircularRanges.d.ts +3 -2
- package/getZeroedRangeOverlaps.d.ts +2 -1
- package/index.cjs +52 -41
- package/index.d.ts +1 -0
- package/index.js +52 -41
- package/index.umd.cjs +52 -41
- package/invertRange.d.ts +5 -1
- package/isPositionCloserToRangeStartThanRangeEnd.d.ts +2 -1
- package/isPositionWithinRange.d.ts +3 -2
- package/isRangeOrPositionWithinRange.d.ts +2 -1
- package/isRangeWithinRange.d.ts +2 -1
- package/loopEachPositionInRange.d.ts +2 -1
- package/modulatePositionByRange.d.ts +2 -1
- package/modulateRangeBySequenceLength.d.ts +8 -1
- package/normalizePositionByRangeLength.d.ts +1 -1
- package/normalizePositionByRangeLength1Based.d.ts +1 -1
- package/normalizeRange.d.ts +5 -1
- package/package.json +9 -1
- package/provideInclusiveOptions.d.ts +6 -1
- package/reversePositionInRange.d.ts +1 -1
- package/splitRangeIntoTwoPartsIfItIsCircular.d.ts +4 -3
- package/src/RangeAngles.ts +9 -0
- package/src/adjustRangeToDeletionOfAnotherRange.ts +57 -0
- package/src/adjustRangeToInsert.ts +32 -0
- package/src/adjustRangeToRotation.ts +23 -0
- package/src/checkIfNonCircularRangesOverlap.ts +35 -0
- package/src/checkIfPotentiallyCircularRangesOverlap.ts +28 -0
- package/src/collapseOverlapsGeneratedFromRangeComparisonIfPossible.ts +81 -0
- package/src/convertRangeIndices.ts +34 -0
- package/src/convertRangeTo0Based.ts +9 -0
- package/src/convertRangeTo1Based.ts +10 -0
- package/src/doesRangeSpanEntireSequence.ts +12 -0
- package/src/doesRangeSpanOrigin.ts +5 -0
- package/src/expandOrContractCircularRangeToPosition.ts +50 -0
- package/src/expandOrContractNonCircularRangeToPosition.ts +30 -0
- package/src/expandOrContractRangeByLength.ts +18 -0
- package/src/expandOrContractRangeToPosition.ts +16 -0
- package/src/flipContainedRange.ts +156 -0
- package/src/generateRandomRange.ts +26 -0
- package/src/getAnnotationRangeType.ts +30 -0
- package/src/getEachPositionInRangeAsArray.ts +19 -0
- package/src/getLengthOfOverlappingRegionsBetweenTwoRanges.ts +18 -0
- package/src/getMiddleOfRange.ts +11 -0
- package/src/getOverlapOfNonCircularRanges.ts +41 -0
- package/src/getOverlapsOfPotentiallyCircularRanges.ts +60 -0
- package/src/getPositionFromAngle.ts +12 -0
- package/src/getRangeAngles.ts +38 -0
- package/src/getRangeLength.test.ts +30 -0
- package/src/getRangeLength.ts +17 -0
- package/src/getRangesBetweenTwoRanges.ts +42 -0
- package/src/getSequenceWithinRange.test.ts +47 -0
- package/src/getSequenceWithinRange.ts +24 -0
- package/src/getShortestDistanceBetweenTwoPositions.test.ts +12 -0
- package/src/getShortestDistanceBetweenTwoPositions.ts +16 -0
- package/src/getYOffsetForPotentiallyCircularRange.ts +37 -0
- package/src/getYOffsetsForPotentiallyCircularRanges.test.ts +17 -0
- package/src/getYOffsetsForPotentiallyCircularRanges.ts +28 -0
- package/src/getZeroedRangeOverlaps.test.ts +65 -0
- package/src/getZeroedRangeOverlaps.ts +33 -0
- package/src/index.test.ts +39 -0
- package/src/index.ts +53 -0
- package/src/invertRange.ts +25 -0
- package/src/isPositionCloserToRangeStartThanRangeEnd.ts +22 -0
- package/src/isPositionWithinRange.ts +40 -0
- package/src/isRangeOrPositionWithinRange.ts +40 -0
- package/src/isRangeWithinRange.ts +18 -0
- package/src/loopEachPositionInRange.ts +11 -0
- package/src/modulatePositionByRange.ts +15 -0
- package/src/modulateRangeBySequenceLength.ts +13 -0
- package/src/normalizePositionByRangeLength.ts +24 -0
- package/src/normalizePositionByRangeLength1Based.ts +9 -0
- package/src/normalizeRange.ts +12 -0
- package/src/provideInclusiveOptions.ts +79 -0
- package/src/reversePositionInRange.ts +17 -0
- package/src/splitRangeIntoTwoPartsIfItIsCircular.ts +36 -0
- package/src/translateRange.ts +21 -0
- package/src/trimAnnStartEndToFitSeqLength.ts +9 -0
- package/src/trimNonCicularRangeByAnotherNonCircularRange.ts +63 -0
- package/src/trimNumberToFitWithin0ToAnotherNumber.ts +15 -0
- package/src/trimRangeByAnotherRange.ts +103 -0
- package/src/types.ts +12 -0
- package/src/zeroSubrangeByContainerRange.ts +49 -0
- package/translateRange.d.ts +5 -1
- package/trimAnnStartEndToFitSeqLength.d.ts +1 -1
- package/trimNonCicularRangeByAnotherNonCircularRange.d.ts +2 -4
- package/trimNumberToFitWithin0ToAnotherNumber.d.ts +1 -1
- package/trimRangeByAnotherRange.d.ts +2 -1
- package/types.d.ts +12 -0
- package/zeroSubrangeByContainerRange.d.ts +2 -1
package/RangeAngles.d.ts
ADDED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
import { Range } from './types';
|
|
2
|
+
export default function adjustRangeToDeletionOfAnotherRange(rangeToBeAdjusted: Range, anotherRange: Range, maxLength: number): Range | null;
|
package/adjustRangeToInsert.d.ts
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
import { Range } from './types';
|
|
2
|
+
export default function adjustRangeToInsert(rangeToBeAdjusted: Range, insertStart: number, insertLength: number): Range;
|
|
@@ -1 +1,5 @@
|
|
|
1
|
-
|
|
1
|
+
import { Range } from './types';
|
|
2
|
+
export default function adjustRangeToRotation(rangeToBeAdjusted: Range, rotateTo?: number, rangeLength?: number): Range & {
|
|
3
|
+
start: number;
|
|
4
|
+
end: number;
|
|
5
|
+
};
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
import { Range } from './types';
|
|
2
|
+
export default function checkIfNonCircularRangesOverlap(range: Range, comparisonRange: Range): boolean;
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
import { Range } from './types';
|
|
2
|
+
export default function checkIfPotentiallyCircularRangesOverlap(range: Range, comparisonRange: Range): boolean;
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
import { Range } from './types';
|
|
2
|
+
export default function collapseOverlapsGeneratedFromRangeComparisonIfPossible(overlaps: Range[], sequenceLength: number, optionalOriginalRange?: Range): Range[];
|
package/convertRangeIndices.d.ts
CHANGED
|
@@ -1 +1,10 @@
|
|
|
1
|
-
|
|
1
|
+
import { Range } from './types';
|
|
2
|
+
interface RangeIndicesOptions {
|
|
3
|
+
inclusive1BasedStart?: boolean;
|
|
4
|
+
inclusive1BasedEnd?: boolean;
|
|
5
|
+
}
|
|
6
|
+
export default function convertRangeIndices(range: Range, inputType?: RangeIndicesOptions, outputType?: RangeIndicesOptions): Range & {
|
|
7
|
+
start: number;
|
|
8
|
+
end: number;
|
|
9
|
+
};
|
|
10
|
+
export {};
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
import { Range } from './types';
|
|
2
|
+
export default function doesRangeSpanEntireSequence(range: Range, sequenceLength: number): boolean;
|
package/doesRangeSpanOrigin.d.ts
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
import { Range } from './types';
|
|
2
|
+
export default function doesRangeSpanOrigin(range: Range): boolean;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import { Range } from './types';
|
|
2
|
+
export default function expandOrContractCircularRangeToPosition(range: Range, position: number, maxLength: number): {
|
|
3
|
+
newRange: Range;
|
|
3
4
|
endMoved: boolean;
|
|
4
5
|
};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import { Range } from './types';
|
|
2
|
+
export default function expandOrContractNonCircularRangeToPosition(range: Range, position: number): {
|
|
3
|
+
newRange: Range;
|
|
3
4
|
endMoved: boolean;
|
|
4
5
|
};
|
|
@@ -1 +1,5 @@
|
|
|
1
|
-
|
|
1
|
+
import { Range } from './types';
|
|
2
|
+
export default function expandOrContractRangeByLength(range: Range, shiftBy: number, shiftStart: boolean, sequenceLength: number): Range & {
|
|
3
|
+
start: number;
|
|
4
|
+
end: number;
|
|
5
|
+
};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import { Range } from './types';
|
|
2
|
+
export default function expandOrContractRangeToPosition(range: Range, position: number, maxLength: number): {
|
|
3
|
+
newRange: Range;
|
|
3
4
|
endMoved: boolean;
|
|
4
5
|
};
|
package/flipContainedRange.d.ts
CHANGED
|
@@ -1 +1,5 @@
|
|
|
1
|
-
|
|
1
|
+
import { Range } from './types';
|
|
2
|
+
export default function flipRelativeRange(innerRange: Range, outerRange: Range, sequenceLength: number): Range & {
|
|
3
|
+
start: number;
|
|
4
|
+
end: number;
|
|
5
|
+
};
|
package/generateRandomRange.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export default function generateRandomRange(minStart:
|
|
2
|
-
start:
|
|
3
|
-
end:
|
|
1
|
+
export default function generateRandomRange(minStart: number, maxEnd: number, maxLength: number): {
|
|
2
|
+
start: number;
|
|
3
|
+
end: number;
|
|
4
4
|
};
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
import { Range } from './types';
|
|
2
|
+
export default function getAnnotationRangeType(annotationRange: Range, enclosingRangeType: Range, forward: boolean): "end" | "beginningAndEnd" | "start" | "middle";
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
import { Range } from './types';
|
|
2
|
+
export default function getEachPositionInRangeAsArray(range: Range, rangeMax: number): number[];
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
import { Range } from './types';
|
|
2
|
+
export default function getLengthOfOverlappingRegionsBetweenTwoRanges(rangeA: Range, rangeB: Range, maxLength: number): number;
|
package/getMiddleOfRange.d.ts
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
import { Range } from './types';
|
|
2
|
+
export default function getMiddleOfRange(range: Range, rangeMax: number): number;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import { Range } from './types';
|
|
2
|
+
export default function getOverlapOfNonCircularRanges(rangeA: Range, rangeB: Range): {
|
|
3
|
+
start: number;
|
|
4
|
+
end: number;
|
|
5
|
+
} | null;
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
import { Range } from './types';
|
|
2
|
+
export default function getOverlapsOfPotentiallyCircularRanges(rangeA: Range, rangeB: Range, maxRangeLength: number, joinIfPossible?: boolean): Range[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export default function getPositionFromAngle(angle:
|
|
1
|
+
export default function getPositionFromAngle(angle: number, rangeMax: number, isInBetweenPositions?: boolean): number;
|
package/getRangeAngles.d.ts
CHANGED
|
@@ -1,7 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
endAngle: number;
|
|
5
|
-
centerAngle: number;
|
|
6
|
-
locationAngles: any;
|
|
7
|
-
};
|
|
1
|
+
import { Range } from './types';
|
|
2
|
+
import { RangeAngles } from './RangeAngles';
|
|
3
|
+
export default function getRangeAngles(range: Range, rangeMax: number): RangeAngles;
|
package/getRangeLength.d.ts
CHANGED
|
@@ -1,2 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
import { Range } from './types';
|
|
2
|
+
declare const _default: (range: Range, rangeMax: number, options?: {
|
|
3
|
+
inclusive1BasedEnd?: boolean;
|
|
4
|
+
inclusive1BasedStart?: boolean;
|
|
5
|
+
} | undefined) => number;
|
|
2
6
|
export default _default;
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
import { Range } from './types';
|
|
2
|
+
export default function getRangesBetweenTwoRanges(range1: Range, range2: Range): Range[];
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
import { Range } from './types';
|
|
2
|
+
export default function getSequenceWithinRange<T>(range: Range, sequence: string | T[]): string | T[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export default function getShortestDistanceBetweenTwoPositions(position1:
|
|
1
|
+
export default function getShortestDistanceBetweenTwoPositions(position1: number, position2: number, sequenceLength: number): number;
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
import { Range } from './types';
|
|
2
|
+
export default function getYOffsetForPotentiallyCircularRange(range: Range, YOffsetLevelsWithRanges: Range[][], assignYOffsetToRange: boolean): number;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import { Range } from './types';
|
|
2
|
+
export default function getYOffsetsForPotentiallyCircularRanges(ranges: Range[], assignYOffsetToRange: boolean): {
|
|
3
|
+
yOffsets: number[];
|
|
3
4
|
maxYOffset: number;
|
|
4
5
|
};
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
import { Range } from './types';
|
|
2
|
+
export default function getZeroedRangeOverlaps(annotation: Range, selection: Range, sequenceLength: number): Range[];
|
package/index.cjs
CHANGED
|
@@ -1566,9 +1566,10 @@ function getOverlapOfNonCircularRanges(rangeA, rangeB) {
|
|
|
1566
1566
|
}
|
|
1567
1567
|
}
|
|
1568
1568
|
}
|
|
1569
|
+
return null;
|
|
1569
1570
|
}
|
|
1570
1571
|
__name(getOverlapOfNonCircularRanges, "getOverlapOfNonCircularRanges");
|
|
1571
|
-
function getOverlapsOfPotentiallyCircularRanges(rangeA, rangeB, maxRangeLength, joinIfPossible) {
|
|
1572
|
+
function getOverlapsOfPotentiallyCircularRanges(rangeA, rangeB, maxRangeLength, joinIfPossible = false) {
|
|
1572
1573
|
const normalizedRangeA = splitRangeIntoTwoPartsIfItIsCircular(
|
|
1573
1574
|
rangeA,
|
|
1574
1575
|
maxRangeLength
|
|
@@ -1599,8 +1600,11 @@ function getOverlapsOfPotentiallyCircularRanges(rangeA, rangeB, maxRangeLength,
|
|
|
1599
1600
|
joinedOverlap.start = o.start;
|
|
1600
1601
|
return [];
|
|
1601
1602
|
}
|
|
1603
|
+
return [o];
|
|
1602
1604
|
});
|
|
1603
|
-
|
|
1605
|
+
if (Object.keys(joinedOverlap).length > 0) {
|
|
1606
|
+
overlaps.push(joinedOverlap);
|
|
1607
|
+
}
|
|
1604
1608
|
}
|
|
1605
1609
|
return overlaps;
|
|
1606
1610
|
}
|
|
@@ -1673,10 +1677,7 @@ function trimRangeByAnotherRange(rangeToBeTrimmed, trimmingRange, sequenceLength
|
|
|
1673
1677
|
if (!overlaps.length) {
|
|
1674
1678
|
return rangeToBeTrimmed;
|
|
1675
1679
|
}
|
|
1676
|
-
const splitRangesToBeTrimmed = splitRangeIntoTwoPartsIfItIsCircular(
|
|
1677
|
-
rangeToBeTrimmed,
|
|
1678
|
-
sequenceLength
|
|
1679
|
-
);
|
|
1680
|
+
const splitRangesToBeTrimmed = splitRangeIntoTwoPartsIfItIsCircular(rangeToBeTrimmed, sequenceLength);
|
|
1680
1681
|
splitRangesToBeTrimmed.forEach(function(nonCircularRangeToBeTrimmed, index) {
|
|
1681
1682
|
overlaps.forEach(function(overlap) {
|
|
1682
1683
|
if (nonCircularRangeToBeTrimmed) {
|
|
@@ -1719,6 +1720,7 @@ function trimRangeByAnotherRange(rangeToBeTrimmed, trimmingRange, sequenceLength
|
|
|
1719
1720
|
end: outputTrimmedRange.end
|
|
1720
1721
|
});
|
|
1721
1722
|
}
|
|
1723
|
+
return void 0;
|
|
1722
1724
|
}
|
|
1723
1725
|
__name(trimRangeByAnotherRange, "trimRangeByAnotherRange");
|
|
1724
1726
|
function adjustRangeToDeletionOfAnotherRange(rangeToBeAdjusted, anotherRange, maxLength) {
|
|
@@ -1865,11 +1867,10 @@ function collapseOverlapsGeneratedFromRangeComparisonIfPossible(overlaps, sequen
|
|
|
1865
1867
|
}
|
|
1866
1868
|
}
|
|
1867
1869
|
}
|
|
1870
|
+
return overlaps;
|
|
1868
1871
|
}
|
|
1869
1872
|
__name(collapseOverlapsGeneratedFromRangeComparisonIfPossible, "collapseOverlapsGeneratedFromRangeComparisonIfPossible");
|
|
1870
|
-
function convertRangeIndices(range, inputType, outputType) {
|
|
1871
|
-
inputType = inputType || {};
|
|
1872
|
-
outputType = outputType || {};
|
|
1873
|
+
function convertRangeIndices(range, inputType = {}, outputType = {}) {
|
|
1873
1874
|
return assign({}, range, {
|
|
1874
1875
|
start: Number(range.start) + (inputType.inclusive1BasedStart ? outputType.inclusive1BasedStart ? 0 : -1 : outputType.inclusive1BasedStart ? 1 : 0),
|
|
1875
1876
|
end: Number(range.end) + (inputType.inclusive1BasedEnd ? outputType.inclusive1BasedEnd ? 0 : -1 : outputType.inclusive1BasedEnd ? 1 : 0)
|
|
@@ -1892,25 +1893,32 @@ function convertRangeTo1Based(range) {
|
|
|
1892
1893
|
}
|
|
1893
1894
|
__name(convertRangeTo1Based, "convertRangeTo1Based");
|
|
1894
1895
|
function provideInclusiveOptions(funToWrap) {
|
|
1895
|
-
return function() {
|
|
1896
|
-
const args = Array.prototype.slice.call(arguments);
|
|
1896
|
+
return function(...args) {
|
|
1897
1897
|
const options = args[args.length - 1];
|
|
1898
1898
|
if (options && (options.inclusive1BasedEnd || options.inclusive1BasedStart)) {
|
|
1899
1899
|
args.forEach(function(arg, index) {
|
|
1900
|
-
|
|
1901
|
-
|
|
1900
|
+
const potentialRange = arg;
|
|
1901
|
+
if (potentialRange && typeof potentialRange.start === "number" && potentialRange.start > -1 && options.inclusive1BasedStart) {
|
|
1902
|
+
args[index] = assign(potentialRange, {
|
|
1903
|
+
start: potentialRange.start - 1
|
|
1904
|
+
});
|
|
1902
1905
|
}
|
|
1903
|
-
if (
|
|
1904
|
-
args[index] = assign(
|
|
1906
|
+
if (potentialRange && typeof potentialRange.end === "number" && potentialRange.end > -1 && options.inclusive1BasedEnd) {
|
|
1907
|
+
args[index] = assign(potentialRange, {
|
|
1908
|
+
end: potentialRange.end - 1
|
|
1909
|
+
});
|
|
1905
1910
|
}
|
|
1906
1911
|
});
|
|
1907
1912
|
}
|
|
1908
1913
|
let returnVal = funToWrap.apply(this, args);
|
|
1909
|
-
|
|
1910
|
-
|
|
1914
|
+
const potentialReturn = returnVal;
|
|
1915
|
+
if (potentialReturn && typeof potentialReturn.start === "number" && potentialReturn.start > -1 && options && options.inclusive1BasedStart) {
|
|
1916
|
+
returnVal = assign(potentialReturn, {
|
|
1917
|
+
start: potentialReturn.start + 1
|
|
1918
|
+
});
|
|
1911
1919
|
}
|
|
1912
|
-
if (
|
|
1913
|
-
returnVal = assign(
|
|
1920
|
+
if (potentialReturn && typeof potentialReturn.end === "number" && potentialReturn.end > -1 && options && options.inclusive1BasedEnd) {
|
|
1921
|
+
returnVal = assign(potentialReturn, { end: potentialReturn.end + 1 });
|
|
1914
1922
|
}
|
|
1915
1923
|
return returnVal;
|
|
1916
1924
|
};
|
|
@@ -1931,9 +1939,10 @@ function getRangeLength$1(range, rangeMax) {
|
|
|
1931
1939
|
}
|
|
1932
1940
|
__name(getRangeLength$1, "getRangeLength$1");
|
|
1933
1941
|
function doesRangeSpanEntireSequence(range, sequenceLength) {
|
|
1934
|
-
if (getRangeLength(range) === sequenceLength) {
|
|
1942
|
+
if (getRangeLength(range, sequenceLength) === sequenceLength) {
|
|
1935
1943
|
return true;
|
|
1936
1944
|
}
|
|
1945
|
+
return false;
|
|
1937
1946
|
}
|
|
1938
1947
|
__name(doesRangeSpanEntireSequence, "doesRangeSpanEntireSequence");
|
|
1939
1948
|
function isRangeWithinRange(rangeToCheck, containingRange, maxLength) {
|
|
@@ -1967,6 +1976,9 @@ function isRangeOrPositionWithinRange(rangeOrPositionToCheck, containingRange, m
|
|
|
1967
1976
|
return false;
|
|
1968
1977
|
}
|
|
1969
1978
|
if (isObject(rangeOrPositionToCheck)) {
|
|
1979
|
+
if (typeof rangeOrPositionToCheck.start !== "number") {
|
|
1980
|
+
return false;
|
|
1981
|
+
}
|
|
1970
1982
|
return isRangeWithinRange(
|
|
1971
1983
|
rangeOrPositionToCheck,
|
|
1972
1984
|
containingRange,
|
|
@@ -1987,7 +1999,7 @@ function doesRangeSpanOrigin(range) {
|
|
|
1987
1999
|
return range.start > range.end;
|
|
1988
2000
|
}
|
|
1989
2001
|
__name(doesRangeSpanOrigin, "doesRangeSpanOrigin");
|
|
1990
|
-
function normalizePositionByRangeLength(pPosition, sequenceLength, isInBetweenPositions) {
|
|
2002
|
+
function normalizePositionByRangeLength(pPosition, sequenceLength, isInBetweenPositions = false) {
|
|
1991
2003
|
let position = pPosition;
|
|
1992
2004
|
if (position < 0) {
|
|
1993
2005
|
position += sequenceLength;
|
|
@@ -2079,10 +2091,7 @@ function expandOrContractRangeToPosition(range, position, maxLength) {
|
|
|
2079
2091
|
if (range.start > range.end) {
|
|
2080
2092
|
return expandOrContractCircularRangeToPosition(range, position, maxLength);
|
|
2081
2093
|
} else {
|
|
2082
|
-
return expandOrContractNonCircularRangeToPosition(
|
|
2083
|
-
range,
|
|
2084
|
-
position
|
|
2085
|
-
);
|
|
2094
|
+
return expandOrContractNonCircularRangeToPosition(range, position);
|
|
2086
2095
|
}
|
|
2087
2096
|
}
|
|
2088
2097
|
__name(expandOrContractRangeToPosition, "expandOrContractRangeToPosition");
|
|
@@ -2346,7 +2355,9 @@ function getSequenceWithinRange(range, sequence) {
|
|
|
2346
2355
|
if (typeof subSequence === "string") {
|
|
2347
2356
|
subSequence += sequence.slice(0, range.end + 1);
|
|
2348
2357
|
} else {
|
|
2349
|
-
subSequence = subSequence.concat(
|
|
2358
|
+
subSequence = subSequence.concat(
|
|
2359
|
+
sequence.slice(0, range.end + 1)
|
|
2360
|
+
);
|
|
2350
2361
|
}
|
|
2351
2362
|
return subSequence;
|
|
2352
2363
|
} else {
|
|
@@ -2366,7 +2377,7 @@ function getShortestDistanceBetweenTwoPositions(position1, position2, sequenceLe
|
|
|
2366
2377
|
}
|
|
2367
2378
|
__name(getShortestDistanceBetweenTwoPositions, "getShortestDistanceBetweenTwoPositions");
|
|
2368
2379
|
function getYOffsetForPotentiallyCircularRange(range, YOffsetLevelsWithRanges, assignYOffsetToRange) {
|
|
2369
|
-
let yOffset =
|
|
2380
|
+
let yOffset = 0;
|
|
2370
2381
|
const openYOffsetFound = YOffsetLevelsWithRanges.some(
|
|
2371
2382
|
function(rangesAlreadyAddedToYOffset, index) {
|
|
2372
2383
|
const rangeBlocked = rangesAlreadyAddedToYOffset.some(
|
|
@@ -2416,21 +2427,20 @@ function getYOffsetsForPotentiallyCircularRanges(ranges, assignYOffsetToRange) {
|
|
|
2416
2427
|
__name(getYOffsetsForPotentiallyCircularRanges, "getYOffsetsForPotentiallyCircularRanges");
|
|
2417
2428
|
const invertRange = provideInclusiveOptions(invertRange$1);
|
|
2418
2429
|
function invertRange$1(rangeOrCaret, rangeMax) {
|
|
2419
|
-
if (rangeOrCaret.start > -1) {
|
|
2430
|
+
if (typeof rangeOrCaret !== "number" && rangeOrCaret.start > -1) {
|
|
2420
2431
|
const start = rangeOrCaret.end + 1;
|
|
2421
2432
|
const end = rangeOrCaret.start - 1;
|
|
2422
2433
|
return {
|
|
2423
2434
|
start: normalizePositionByRangeLength(start, rangeMax, false),
|
|
2424
2435
|
end: normalizePositionByRangeLength(end, rangeMax, false)
|
|
2425
2436
|
};
|
|
2426
|
-
} else {
|
|
2427
|
-
|
|
2428
|
-
|
|
2429
|
-
|
|
2430
|
-
|
|
2431
|
-
};
|
|
2432
|
-
}
|
|
2437
|
+
} else if (typeof rangeOrCaret === "number" && rangeOrCaret > -1) {
|
|
2438
|
+
return {
|
|
2439
|
+
start: normalizePositionByRangeLength(rangeOrCaret, rangeMax, false),
|
|
2440
|
+
end: normalizePositionByRangeLength(rangeOrCaret - 1, rangeMax, false)
|
|
2441
|
+
};
|
|
2433
2442
|
}
|
|
2443
|
+
return void 0;
|
|
2434
2444
|
}
|
|
2435
2445
|
__name(invertRange$1, "invertRange$1");
|
|
2436
2446
|
function isPositionCloserToRangeStartThanRangeEnd(position, range, maxLength) {
|
|
@@ -2498,9 +2508,10 @@ function zeroSubrangeByContainerRange(subRange, containerRange, sequenceLength)
|
|
|
2498
2508
|
"subRange must be fully contained by containerRange! Otherwise this function does not make sense"
|
|
2499
2509
|
);
|
|
2500
2510
|
}
|
|
2501
|
-
const newSubrange = {
|
|
2502
|
-
|
|
2503
|
-
|
|
2511
|
+
const newSubrange = {
|
|
2512
|
+
start: subRange.start - containerRange.start,
|
|
2513
|
+
end: subRange.end - containerRange.start
|
|
2514
|
+
};
|
|
2504
2515
|
if (newSubrange.start < 0) {
|
|
2505
2516
|
newSubrange.start += sequenceLength;
|
|
2506
2517
|
}
|
|
@@ -2511,10 +2522,10 @@ function zeroSubrangeByContainerRange(subRange, containerRange, sequenceLength)
|
|
|
2511
2522
|
}
|
|
2512
2523
|
__name(zeroSubrangeByContainerRange, "zeroSubrangeByContainerRange");
|
|
2513
2524
|
function adjustRangeToRotation(rangeToBeAdjusted, rotateTo = 0, rangeLength) {
|
|
2514
|
-
const mod = rangeLength ? modulo :
|
|
2525
|
+
const mod = /* @__PURE__ */ __name((n) => rangeLength ? modulo(n, rangeLength) : n, "mod");
|
|
2515
2526
|
const newRange = assign({}, rangeToBeAdjusted, {
|
|
2516
|
-
start: mod(rangeToBeAdjusted.start - (rotateTo || 0)
|
|
2517
|
-
end: mod(rangeToBeAdjusted.end - (rotateTo || 0)
|
|
2527
|
+
start: mod(rangeToBeAdjusted.start - (rotateTo || 0)),
|
|
2528
|
+
end: mod(rangeToBeAdjusted.end - (rotateTo || 0))
|
|
2518
2529
|
});
|
|
2519
2530
|
return newRange;
|
|
2520
2531
|
}
|
package/index.d.ts
CHANGED
|
@@ -50,3 +50,4 @@ export { default as zeroSubrangeByContainerRange } from './zeroSubrangeByContain
|
|
|
50
50
|
export { default as adjustRangeToRotation } from './adjustRangeToRotation';
|
|
51
51
|
export { default as getZeroedRangeOverlaps } from './getZeroedRangeOverlaps';
|
|
52
52
|
export { default as trimAnnStartEndToFitSeqLength } from './trimAnnStartEndToFitSeqLength';
|
|
53
|
+
export * from './types';
|