@teselagen/range-utils 0.3.18 → 0.3.20-beta.1
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/README.md +0 -10
- package/RangeAngles.d.ts +7 -0
- package/adjustRangeToDeletionOfAnotherRange.d.ts +2 -1
- package/adjustRangeToInsert.d.ts +2 -1
- package/adjustRangeToRotation.d.ts +2 -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 +3 -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 +58 -45
- package/index.d.ts +1 -0
- package/index.js +58 -45
- package/index.umd.cjs +58 -45
- 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 +10 -2
- 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.js → adjustRangeToDeletionOfAnotherRange.ts} +4 -7
- package/src/{adjustRangeToInsert.js → adjustRangeToInsert.ts} +4 -4
- package/src/adjustRangeToRotation.ts +22 -0
- package/src/{checkIfNonCircularRangesOverlap.js → checkIfNonCircularRangesOverlap.ts} +5 -4
- package/src/{checkIfPotentiallyCircularRangesOverlap.js → checkIfPotentiallyCircularRangesOverlap.ts} +4 -4
- package/src/{collapseOverlapsGeneratedFromRangeComparisonIfPossible.js → collapseOverlapsGeneratedFromRangeComparisonIfPossible.ts} +7 -4
- package/src/{convertRangeIndices.js → convertRangeIndices.ts} +11 -3
- package/src/{convertRangeTo0Based.js → convertRangeTo0Based.ts} +2 -1
- package/src/{convertRangeTo1Based.js → convertRangeTo1Based.ts} +2 -1
- package/src/doesRangeSpanEntireSequence.ts +12 -0
- package/src/doesRangeSpanOrigin.ts +5 -0
- package/src/{expandOrContractCircularRangeToPosition.js → expandOrContractCircularRangeToPosition.ts} +5 -3
- package/src/{expandOrContractNonCircularRangeToPosition.js → expandOrContractNonCircularRangeToPosition.ts} +4 -2
- package/src/{expandOrContractRangeByLength.js → expandOrContractRangeByLength.ts} +5 -4
- package/src/{expandOrContractRangeToPosition.js → expandOrContractRangeToPosition.ts} +6 -8
- package/src/{flipContainedRange.js → flipContainedRange.ts} +18 -8
- package/src/{generateRandomRange.js → generateRandomRange.ts} +6 -2
- package/src/{getAnnotationRangeType.js → getAnnotationRangeType.ts} +5 -3
- package/src/{getEachPositionInRangeAsArray.js → getEachPositionInRangeAsArray.ts} +6 -2
- package/src/{getLengthOfOverlappingRegionsBetweenTwoRanges.js → getLengthOfOverlappingRegionsBetweenTwoRanges.ts} +4 -3
- package/src/{getMiddleOfRange.js → getMiddleOfRange.ts} +2 -1
- package/src/{getOverlapOfNonCircularRanges.js → getOverlapOfNonCircularRanges.ts} +7 -1
- package/src/{getOverlapsOfPotentiallyCircularRanges.js → getOverlapsOfPotentiallyCircularRanges.ts} +13 -7
- package/src/{getPositionFromAngle.js → getPositionFromAngle.ts} +3 -3
- package/src/{getRangeAngles.js → getRangeAngles.ts} +8 -3
- package/src/{getRangeLength.js → getRangeLength.ts} +4 -1
- package/src/{getRangesBetweenTwoRanges.js → getRangesBetweenTwoRanges.ts} +7 -2
- package/src/getSequenceWithinRange.ts +33 -0
- package/src/{getShortestDistanceBetweenTwoPositions.js → getShortestDistanceBetweenTwoPositions.ts} +3 -3
- package/src/{getYOffsetForPotentiallyCircularRange.js → getYOffsetForPotentiallyCircularRange.ts} +5 -4
- package/src/getYOffsetsForPotentiallyCircularRanges.test.ts +17 -0
- package/src/{getYOffsetsForPotentiallyCircularRanges.js → getYOffsetsForPotentiallyCircularRanges.ts} +5 -4
- package/src/{getZeroedRangeOverlaps.test.js → getZeroedRangeOverlaps.test.ts} +5 -15
- package/src/{getZeroedRangeOverlaps.js → getZeroedRangeOverlaps.ts} +4 -3
- package/src/{index.test.js → index.test.ts} +11 -3
- package/src/{index.js → index.ts} +1 -0
- package/src/invertRange.ts +25 -0
- package/src/{isPositionCloserToRangeStartThanRangeEnd.js → isPositionCloserToRangeStartThanRangeEnd.ts} +5 -3
- package/src/{isPositionWithinRange.js → isPositionWithinRange.ts} +14 -5
- package/src/{isRangeOrPositionWithinRange.js → isRangeOrPositionWithinRange.ts} +11 -6
- package/src/{isRangeWithinRange.js → isRangeWithinRange.ts} +5 -3
- package/src/loopEachPositionInRange.ts +11 -0
- package/src/{modulatePositionByRange.js → modulatePositionByRange.ts} +6 -1
- package/src/{modulateRangeBySequenceLength.js → modulateRangeBySequenceLength.ts} +3 -1
- package/src/{normalizePositionByRangeLength.js → normalizePositionByRangeLength.ts} +7 -7
- package/src/{normalizePositionByRangeLength1Based.js → normalizePositionByRangeLength1Based.ts} +3 -2
- package/src/{normalizeRange.js → normalizeRange.ts} +2 -1
- package/src/provideInclusiveOptions.ts +79 -0
- package/src/{reversePositionInRange.js → reversePositionInRange.ts} +4 -4
- package/src/{splitRangeIntoTwoPartsIfItIsCircular.js → splitRangeIntoTwoPartsIfItIsCircular.ts} +5 -4
- package/src/{translateRange.js → translateRange.ts} +5 -3
- package/src/{trimAnnStartEndToFitSeqLength.js → trimAnnStartEndToFitSeqLength.ts} +2 -2
- package/src/{trimNonCicularRangeByAnotherNonCircularRange.js → trimNonCicularRangeByAnotherNonCircularRange.ts} +6 -4
- package/src/{trimNumberToFitWithin0ToAnotherNumber.js → trimNumberToFitWithin0ToAnotherNumber.ts} +3 -4
- package/src/{trimRangeByAnotherRange.js → trimRangeByAnotherRange.ts} +9 -9
- package/src/types.ts +12 -0
- package/src/{zeroSubrangeByContainerRange.js → zeroSubrangeByContainerRange.ts} +10 -8
- 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/adjustRangeToDeletionOfAnotherRange.test.d.ts +0 -1
- package/adjustRangeToInsert.test.d.ts +0 -1
- package/adjustRangeToRotation.test.d.ts +0 -1
- package/checkIfNonCircularRangesOverlap.test.d.ts +0 -1
- package/checkIfPotentiallyCircularRangesOverlap.test.d.ts +0 -1
- package/collapseOverlapsGeneratedFromRangeComparisonIfPossible.test.d.ts +0 -1
- package/convertRangeIndices.test.d.ts +0 -1
- package/expandOrContractRangeByLength.test.d.ts +0 -1
- package/flipContainedRange.test.d.ts +0 -1
- package/generateRandomRange.test.d.ts +0 -1
- package/getAnnotationRangeType.test.d.ts +0 -1
- package/getEachPositionInRangeAsArray.test.d.ts +0 -1
- package/getLengthOfOverlappingRegionsBetweenTwoRanges.test.d.ts +0 -1
- package/getMiddleOfRange.test.d.ts +0 -1
- package/getOverlapsOfPotentiallyCircularRanges.test.d.ts +0 -1
- package/getRangeAngles.test.d.ts +0 -1
- package/getRangeLength.test.d.ts +0 -1
- package/getSequenceWithinRange.test.d.ts +0 -1
- package/getShortestDistanceBetweenTwoPositions.test.d.ts +0 -1
- package/getYOffsetsForPotentiallyCircularRanges.test.d.ts +0 -1
- package/getZeroedRangeOverlaps.test.d.ts +0 -1
- package/index.test.d.ts +0 -1
- package/invertRange.test.d.ts +0 -1
- package/isPositionCloserToRangeStartThanRangeEnd.test.d.ts +0 -1
- package/isRangeOrPositionWithinRange.test.d.ts +0 -1
- package/modulatePositionByRange.test.d.ts +0 -1
- package/modulateRangeBySequenceLength.test.d.ts +0 -1
- package/normalizePositionByRangeLength.test.d.ts +0 -1
- package/normalizePositionByRangeLength1Based.test.d.ts +0 -1
- package/normalizeRange.test.d.ts +0 -1
- package/splitRangeIntoTwoPartsIfItIsCircular.test.d.ts +0 -1
- package/src/adjustRangeToRotation.js +0 -23
- package/src/doesRangeSpanEntireSequence.js +0 -7
- package/src/doesRangeSpanOrigin.js +0 -3
- package/src/getSequenceWithinRange.js +0 -17
- package/src/getYOffsetsForPotentiallyCircularRanges.test.js +0 -42
- package/src/invertRange.js +0 -21
- package/src/loopEachPositionInRange.js +0 -5
- package/src/provideInclusiveOptions.js +0 -39
- package/translateRange.test.d.ts +0 -1
- package/trimAnnStartEndToFitSeqLength.test.d.ts +0 -1
- package/trimRangeByAnotherRange.test.d.ts +0 -1
- package/zeroSubrangeByContainerRange.test.d.ts +0 -1
- /package/src/{getRangeLength.test.js → getRangeLength.test.ts} +0 -0
- /package/src/{getSequenceWithinRange.test.js → getSequenceWithinRange.test.ts} +0 -0
- /package/src/{getShortestDistanceBetweenTwoPositions.test.js → getShortestDistanceBetweenTwoPositions.test.ts} +0 -0
package/index.js
CHANGED
|
@@ -1564,9 +1564,10 @@ function getOverlapOfNonCircularRanges(rangeA, rangeB) {
|
|
|
1564
1564
|
}
|
|
1565
1565
|
}
|
|
1566
1566
|
}
|
|
1567
|
+
return null;
|
|
1567
1568
|
}
|
|
1568
1569
|
__name(getOverlapOfNonCircularRanges, "getOverlapOfNonCircularRanges");
|
|
1569
|
-
function getOverlapsOfPotentiallyCircularRanges(rangeA, rangeB, maxRangeLength, joinIfPossible) {
|
|
1570
|
+
function getOverlapsOfPotentiallyCircularRanges(rangeA, rangeB, maxRangeLength, joinIfPossible = false) {
|
|
1570
1571
|
const normalizedRangeA = splitRangeIntoTwoPartsIfItIsCircular(
|
|
1571
1572
|
rangeA,
|
|
1572
1573
|
maxRangeLength
|
|
@@ -1597,8 +1598,11 @@ function getOverlapsOfPotentiallyCircularRanges(rangeA, rangeB, maxRangeLength,
|
|
|
1597
1598
|
joinedOverlap.start = o.start;
|
|
1598
1599
|
return [];
|
|
1599
1600
|
}
|
|
1601
|
+
return [o];
|
|
1600
1602
|
});
|
|
1601
|
-
|
|
1603
|
+
if (Object.keys(joinedOverlap).length > 0) {
|
|
1604
|
+
overlaps.push(joinedOverlap);
|
|
1605
|
+
}
|
|
1602
1606
|
}
|
|
1603
1607
|
return overlaps;
|
|
1604
1608
|
}
|
|
@@ -1671,10 +1675,7 @@ function trimRangeByAnotherRange(rangeToBeTrimmed, trimmingRange, sequenceLength
|
|
|
1671
1675
|
if (!overlaps.length) {
|
|
1672
1676
|
return rangeToBeTrimmed;
|
|
1673
1677
|
}
|
|
1674
|
-
const splitRangesToBeTrimmed = splitRangeIntoTwoPartsIfItIsCircular(
|
|
1675
|
-
rangeToBeTrimmed,
|
|
1676
|
-
sequenceLength
|
|
1677
|
-
);
|
|
1678
|
+
const splitRangesToBeTrimmed = splitRangeIntoTwoPartsIfItIsCircular(rangeToBeTrimmed, sequenceLength);
|
|
1678
1679
|
splitRangesToBeTrimmed.forEach(function(nonCircularRangeToBeTrimmed, index) {
|
|
1679
1680
|
overlaps.forEach(function(overlap) {
|
|
1680
1681
|
if (nonCircularRangeToBeTrimmed) {
|
|
@@ -1717,6 +1718,7 @@ function trimRangeByAnotherRange(rangeToBeTrimmed, trimmingRange, sequenceLength
|
|
|
1717
1718
|
end: outputTrimmedRange.end
|
|
1718
1719
|
});
|
|
1719
1720
|
}
|
|
1721
|
+
return void 0;
|
|
1720
1722
|
}
|
|
1721
1723
|
__name(trimRangeByAnotherRange, "trimRangeByAnotherRange");
|
|
1722
1724
|
function adjustRangeToDeletionOfAnotherRange(rangeToBeAdjusted, anotherRange, maxLength) {
|
|
@@ -1863,11 +1865,10 @@ function collapseOverlapsGeneratedFromRangeComparisonIfPossible(overlaps, sequen
|
|
|
1863
1865
|
}
|
|
1864
1866
|
}
|
|
1865
1867
|
}
|
|
1868
|
+
return overlaps;
|
|
1866
1869
|
}
|
|
1867
1870
|
__name(collapseOverlapsGeneratedFromRangeComparisonIfPossible, "collapseOverlapsGeneratedFromRangeComparisonIfPossible");
|
|
1868
|
-
function convertRangeIndices(range, inputType, outputType) {
|
|
1869
|
-
inputType = inputType || {};
|
|
1870
|
-
outputType = outputType || {};
|
|
1871
|
+
function convertRangeIndices(range, inputType = {}, outputType = {}) {
|
|
1871
1872
|
return assign({}, range, {
|
|
1872
1873
|
start: Number(range.start) + (inputType.inclusive1BasedStart ? outputType.inclusive1BasedStart ? 0 : -1 : outputType.inclusive1BasedStart ? 1 : 0),
|
|
1873
1874
|
end: Number(range.end) + (inputType.inclusive1BasedEnd ? outputType.inclusive1BasedEnd ? 0 : -1 : outputType.inclusive1BasedEnd ? 1 : 0)
|
|
@@ -1890,25 +1891,32 @@ function convertRangeTo1Based(range) {
|
|
|
1890
1891
|
}
|
|
1891
1892
|
__name(convertRangeTo1Based, "convertRangeTo1Based");
|
|
1892
1893
|
function provideInclusiveOptions(funToWrap) {
|
|
1893
|
-
return function() {
|
|
1894
|
-
const args = Array.prototype.slice.call(arguments);
|
|
1894
|
+
return function(...args) {
|
|
1895
1895
|
const options = args[args.length - 1];
|
|
1896
1896
|
if (options && (options.inclusive1BasedEnd || options.inclusive1BasedStart)) {
|
|
1897
1897
|
args.forEach(function(arg, index) {
|
|
1898
|
-
|
|
1899
|
-
|
|
1898
|
+
const potentialRange = arg;
|
|
1899
|
+
if (potentialRange && typeof potentialRange.start === "number" && potentialRange.start > -1 && options.inclusive1BasedStart) {
|
|
1900
|
+
args[index] = assign(potentialRange, {
|
|
1901
|
+
start: potentialRange.start - 1
|
|
1902
|
+
});
|
|
1900
1903
|
}
|
|
1901
|
-
if (
|
|
1902
|
-
args[index] = assign(
|
|
1904
|
+
if (potentialRange && typeof potentialRange.end === "number" && potentialRange.end > -1 && options.inclusive1BasedEnd) {
|
|
1905
|
+
args[index] = assign(potentialRange, {
|
|
1906
|
+
end: potentialRange.end - 1
|
|
1907
|
+
});
|
|
1903
1908
|
}
|
|
1904
1909
|
});
|
|
1905
1910
|
}
|
|
1906
1911
|
let returnVal = funToWrap.apply(this, args);
|
|
1907
|
-
|
|
1908
|
-
|
|
1912
|
+
const potentialReturn = returnVal;
|
|
1913
|
+
if (potentialReturn && typeof potentialReturn.start === "number" && potentialReturn.start > -1 && options && options.inclusive1BasedStart) {
|
|
1914
|
+
returnVal = assign(potentialReturn, {
|
|
1915
|
+
start: potentialReturn.start + 1
|
|
1916
|
+
});
|
|
1909
1917
|
}
|
|
1910
|
-
if (
|
|
1911
|
-
returnVal = assign(
|
|
1918
|
+
if (potentialReturn && typeof potentialReturn.end === "number" && potentialReturn.end > -1 && options && options.inclusive1BasedEnd) {
|
|
1919
|
+
returnVal = assign(potentialReturn, { end: potentialReturn.end + 1 });
|
|
1912
1920
|
}
|
|
1913
1921
|
return returnVal;
|
|
1914
1922
|
};
|
|
@@ -1929,9 +1937,10 @@ function getRangeLength$1(range, rangeMax) {
|
|
|
1929
1937
|
}
|
|
1930
1938
|
__name(getRangeLength$1, "getRangeLength$1");
|
|
1931
1939
|
function doesRangeSpanEntireSequence(range, sequenceLength) {
|
|
1932
|
-
if (getRangeLength(range) === sequenceLength) {
|
|
1940
|
+
if (getRangeLength(range, sequenceLength) === sequenceLength) {
|
|
1933
1941
|
return true;
|
|
1934
1942
|
}
|
|
1943
|
+
return false;
|
|
1935
1944
|
}
|
|
1936
1945
|
__name(doesRangeSpanEntireSequence, "doesRangeSpanEntireSequence");
|
|
1937
1946
|
function isRangeWithinRange(rangeToCheck, containingRange, maxLength) {
|
|
@@ -1965,6 +1974,9 @@ function isRangeOrPositionWithinRange(rangeOrPositionToCheck, containingRange, m
|
|
|
1965
1974
|
return false;
|
|
1966
1975
|
}
|
|
1967
1976
|
if (isObject(rangeOrPositionToCheck)) {
|
|
1977
|
+
if (typeof rangeOrPositionToCheck.start !== "number") {
|
|
1978
|
+
return false;
|
|
1979
|
+
}
|
|
1968
1980
|
return isRangeWithinRange(
|
|
1969
1981
|
rangeOrPositionToCheck,
|
|
1970
1982
|
containingRange,
|
|
@@ -1985,7 +1997,7 @@ function doesRangeSpanOrigin(range) {
|
|
|
1985
1997
|
return range.start > range.end;
|
|
1986
1998
|
}
|
|
1987
1999
|
__name(doesRangeSpanOrigin, "doesRangeSpanOrigin");
|
|
1988
|
-
function normalizePositionByRangeLength(pPosition, sequenceLength, isInBetweenPositions) {
|
|
2000
|
+
function normalizePositionByRangeLength(pPosition, sequenceLength, isInBetweenPositions = false) {
|
|
1989
2001
|
let position = pPosition;
|
|
1990
2002
|
if (position < 0) {
|
|
1991
2003
|
position += sequenceLength;
|
|
@@ -2077,10 +2089,7 @@ function expandOrContractRangeToPosition(range, position, maxLength) {
|
|
|
2077
2089
|
if (range.start > range.end) {
|
|
2078
2090
|
return expandOrContractCircularRangeToPosition(range, position, maxLength);
|
|
2079
2091
|
} else {
|
|
2080
|
-
return expandOrContractNonCircularRangeToPosition(
|
|
2081
|
-
range,
|
|
2082
|
-
position
|
|
2083
|
-
);
|
|
2092
|
+
return expandOrContractNonCircularRangeToPosition(range, position);
|
|
2084
2093
|
}
|
|
2085
2094
|
}
|
|
2086
2095
|
__name(expandOrContractRangeToPosition, "expandOrContractRangeToPosition");
|
|
@@ -2338,15 +2347,19 @@ function getRangesBetweenTwoRanges(range1, range2) {
|
|
|
2338
2347
|
}
|
|
2339
2348
|
__name(getRangesBetweenTwoRanges, "getRangesBetweenTwoRanges");
|
|
2340
2349
|
function getSequenceWithinRange(range, sequence) {
|
|
2341
|
-
if (range.start < 0 || range.end < 0)
|
|
2350
|
+
if (range.start < 0 || range.end < 0) {
|
|
2351
|
+
if (typeof sequence === "string") return "";
|
|
2352
|
+
return [];
|
|
2353
|
+
}
|
|
2342
2354
|
if (range.start > range.end) {
|
|
2343
|
-
|
|
2355
|
+
const subSequence = sequence.slice(range.start, sequence.length);
|
|
2344
2356
|
if (typeof subSequence === "string") {
|
|
2345
|
-
subSequence
|
|
2357
|
+
return subSequence + sequence.slice(0, range.end + 1);
|
|
2346
2358
|
} else {
|
|
2347
|
-
|
|
2359
|
+
return subSequence.concat(
|
|
2360
|
+
sequence.slice(0, range.end + 1)
|
|
2361
|
+
);
|
|
2348
2362
|
}
|
|
2349
|
-
return subSequence;
|
|
2350
2363
|
} else {
|
|
2351
2364
|
return sequence.slice(range.start, range.end + 1);
|
|
2352
2365
|
}
|
|
@@ -2364,7 +2377,7 @@ function getShortestDistanceBetweenTwoPositions(position1, position2, sequenceLe
|
|
|
2364
2377
|
}
|
|
2365
2378
|
__name(getShortestDistanceBetweenTwoPositions, "getShortestDistanceBetweenTwoPositions");
|
|
2366
2379
|
function getYOffsetForPotentiallyCircularRange(range, YOffsetLevelsWithRanges, assignYOffsetToRange) {
|
|
2367
|
-
let yOffset =
|
|
2380
|
+
let yOffset = 0;
|
|
2368
2381
|
const openYOffsetFound = YOffsetLevelsWithRanges.some(
|
|
2369
2382
|
function(rangesAlreadyAddedToYOffset, index) {
|
|
2370
2383
|
const rangeBlocked = rangesAlreadyAddedToYOffset.some(
|
|
@@ -2414,21 +2427,20 @@ function getYOffsetsForPotentiallyCircularRanges(ranges, assignYOffsetToRange) {
|
|
|
2414
2427
|
__name(getYOffsetsForPotentiallyCircularRanges, "getYOffsetsForPotentiallyCircularRanges");
|
|
2415
2428
|
const invertRange = provideInclusiveOptions(invertRange$1);
|
|
2416
2429
|
function invertRange$1(rangeOrCaret, rangeMax) {
|
|
2417
|
-
if (rangeOrCaret.start > -1) {
|
|
2430
|
+
if (typeof rangeOrCaret !== "number" && rangeOrCaret.start > -1) {
|
|
2418
2431
|
const start = rangeOrCaret.end + 1;
|
|
2419
2432
|
const end = rangeOrCaret.start - 1;
|
|
2420
2433
|
return {
|
|
2421
2434
|
start: normalizePositionByRangeLength(start, rangeMax, false),
|
|
2422
2435
|
end: normalizePositionByRangeLength(end, rangeMax, false)
|
|
2423
2436
|
};
|
|
2424
|
-
} else {
|
|
2425
|
-
|
|
2426
|
-
|
|
2427
|
-
|
|
2428
|
-
|
|
2429
|
-
};
|
|
2430
|
-
}
|
|
2437
|
+
} else if (typeof rangeOrCaret === "number" && rangeOrCaret > -1) {
|
|
2438
|
+
return {
|
|
2439
|
+
start: normalizePositionByRangeLength(rangeOrCaret, rangeMax, false),
|
|
2440
|
+
end: normalizePositionByRangeLength(rangeOrCaret - 1, rangeMax, false)
|
|
2441
|
+
};
|
|
2431
2442
|
}
|
|
2443
|
+
return void 0;
|
|
2432
2444
|
}
|
|
2433
2445
|
__name(invertRange$1, "invertRange$1");
|
|
2434
2446
|
function isPositionCloserToRangeStartThanRangeEnd(position, range, maxLength) {
|
|
@@ -2496,9 +2508,10 @@ function zeroSubrangeByContainerRange(subRange, containerRange, sequenceLength)
|
|
|
2496
2508
|
"subRange must be fully contained by containerRange! Otherwise this function does not make sense"
|
|
2497
2509
|
);
|
|
2498
2510
|
}
|
|
2499
|
-
const newSubrange = {
|
|
2500
|
-
|
|
2501
|
-
|
|
2511
|
+
const newSubrange = {
|
|
2512
|
+
start: subRange.start - containerRange.start,
|
|
2513
|
+
end: subRange.end - containerRange.start
|
|
2514
|
+
};
|
|
2502
2515
|
if (newSubrange.start < 0) {
|
|
2503
2516
|
newSubrange.start += sequenceLength;
|
|
2504
2517
|
}
|
|
@@ -2509,10 +2522,10 @@ function zeroSubrangeByContainerRange(subRange, containerRange, sequenceLength)
|
|
|
2509
2522
|
}
|
|
2510
2523
|
__name(zeroSubrangeByContainerRange, "zeroSubrangeByContainerRange");
|
|
2511
2524
|
function adjustRangeToRotation(rangeToBeAdjusted, rotateTo = 0, rangeLength) {
|
|
2512
|
-
const mod = rangeLength ? modulo :
|
|
2525
|
+
const mod = /* @__PURE__ */ __name((n) => rangeLength ? modulo(n, rangeLength) : n, "mod");
|
|
2513
2526
|
const newRange = assign({}, rangeToBeAdjusted, {
|
|
2514
|
-
start: mod(rangeToBeAdjusted.start - (rotateTo || 0)
|
|
2515
|
-
end: mod(rangeToBeAdjusted.end - (rotateTo || 0)
|
|
2527
|
+
start: mod(rangeToBeAdjusted.start - (rotateTo || 0)),
|
|
2528
|
+
end: mod(rangeToBeAdjusted.end - (rotateTo || 0))
|
|
2516
2529
|
});
|
|
2517
2530
|
return newRange;
|
|
2518
2531
|
}
|
package/index.umd.cjs
CHANGED
|
@@ -1568,9 +1568,10 @@ var __name = (target, value) => __defProp(target, "name", { value, configurable:
|
|
|
1568
1568
|
}
|
|
1569
1569
|
}
|
|
1570
1570
|
}
|
|
1571
|
+
return null;
|
|
1571
1572
|
}
|
|
1572
1573
|
__name(getOverlapOfNonCircularRanges, "getOverlapOfNonCircularRanges");
|
|
1573
|
-
function getOverlapsOfPotentiallyCircularRanges(rangeA, rangeB, maxRangeLength, joinIfPossible) {
|
|
1574
|
+
function getOverlapsOfPotentiallyCircularRanges(rangeA, rangeB, maxRangeLength, joinIfPossible = false) {
|
|
1574
1575
|
const normalizedRangeA = splitRangeIntoTwoPartsIfItIsCircular(
|
|
1575
1576
|
rangeA,
|
|
1576
1577
|
maxRangeLength
|
|
@@ -1601,8 +1602,11 @@ var __name = (target, value) => __defProp(target, "name", { value, configurable:
|
|
|
1601
1602
|
joinedOverlap.start = o.start;
|
|
1602
1603
|
return [];
|
|
1603
1604
|
}
|
|
1605
|
+
return [o];
|
|
1604
1606
|
});
|
|
1605
|
-
|
|
1607
|
+
if (Object.keys(joinedOverlap).length > 0) {
|
|
1608
|
+
overlaps.push(joinedOverlap);
|
|
1609
|
+
}
|
|
1606
1610
|
}
|
|
1607
1611
|
return overlaps;
|
|
1608
1612
|
}
|
|
@@ -1675,10 +1679,7 @@ var __name = (target, value) => __defProp(target, "name", { value, configurable:
|
|
|
1675
1679
|
if (!overlaps.length) {
|
|
1676
1680
|
return rangeToBeTrimmed;
|
|
1677
1681
|
}
|
|
1678
|
-
const splitRangesToBeTrimmed = splitRangeIntoTwoPartsIfItIsCircular(
|
|
1679
|
-
rangeToBeTrimmed,
|
|
1680
|
-
sequenceLength
|
|
1681
|
-
);
|
|
1682
|
+
const splitRangesToBeTrimmed = splitRangeIntoTwoPartsIfItIsCircular(rangeToBeTrimmed, sequenceLength);
|
|
1682
1683
|
splitRangesToBeTrimmed.forEach(function(nonCircularRangeToBeTrimmed, index) {
|
|
1683
1684
|
overlaps.forEach(function(overlap) {
|
|
1684
1685
|
if (nonCircularRangeToBeTrimmed) {
|
|
@@ -1721,6 +1722,7 @@ var __name = (target, value) => __defProp(target, "name", { value, configurable:
|
|
|
1721
1722
|
end: outputTrimmedRange.end
|
|
1722
1723
|
});
|
|
1723
1724
|
}
|
|
1725
|
+
return void 0;
|
|
1724
1726
|
}
|
|
1725
1727
|
__name(trimRangeByAnotherRange, "trimRangeByAnotherRange");
|
|
1726
1728
|
function adjustRangeToDeletionOfAnotherRange(rangeToBeAdjusted, anotherRange, maxLength) {
|
|
@@ -1867,11 +1869,10 @@ var __name = (target, value) => __defProp(target, "name", { value, configurable:
|
|
|
1867
1869
|
}
|
|
1868
1870
|
}
|
|
1869
1871
|
}
|
|
1872
|
+
return overlaps;
|
|
1870
1873
|
}
|
|
1871
1874
|
__name(collapseOverlapsGeneratedFromRangeComparisonIfPossible, "collapseOverlapsGeneratedFromRangeComparisonIfPossible");
|
|
1872
|
-
function convertRangeIndices(range, inputType, outputType) {
|
|
1873
|
-
inputType = inputType || {};
|
|
1874
|
-
outputType = outputType || {};
|
|
1875
|
+
function convertRangeIndices(range, inputType = {}, outputType = {}) {
|
|
1875
1876
|
return assign({}, range, {
|
|
1876
1877
|
start: Number(range.start) + (inputType.inclusive1BasedStart ? outputType.inclusive1BasedStart ? 0 : -1 : outputType.inclusive1BasedStart ? 1 : 0),
|
|
1877
1878
|
end: Number(range.end) + (inputType.inclusive1BasedEnd ? outputType.inclusive1BasedEnd ? 0 : -1 : outputType.inclusive1BasedEnd ? 1 : 0)
|
|
@@ -1894,25 +1895,32 @@ var __name = (target, value) => __defProp(target, "name", { value, configurable:
|
|
|
1894
1895
|
}
|
|
1895
1896
|
__name(convertRangeTo1Based, "convertRangeTo1Based");
|
|
1896
1897
|
function provideInclusiveOptions(funToWrap) {
|
|
1897
|
-
return function() {
|
|
1898
|
-
const args = Array.prototype.slice.call(arguments);
|
|
1898
|
+
return function(...args) {
|
|
1899
1899
|
const options = args[args.length - 1];
|
|
1900
1900
|
if (options && (options.inclusive1BasedEnd || options.inclusive1BasedStart)) {
|
|
1901
1901
|
args.forEach(function(arg, index) {
|
|
1902
|
-
|
|
1903
|
-
|
|
1902
|
+
const potentialRange = arg;
|
|
1903
|
+
if (potentialRange && typeof potentialRange.start === "number" && potentialRange.start > -1 && options.inclusive1BasedStart) {
|
|
1904
|
+
args[index] = assign(potentialRange, {
|
|
1905
|
+
start: potentialRange.start - 1
|
|
1906
|
+
});
|
|
1904
1907
|
}
|
|
1905
|
-
if (
|
|
1906
|
-
args[index] = assign(
|
|
1908
|
+
if (potentialRange && typeof potentialRange.end === "number" && potentialRange.end > -1 && options.inclusive1BasedEnd) {
|
|
1909
|
+
args[index] = assign(potentialRange, {
|
|
1910
|
+
end: potentialRange.end - 1
|
|
1911
|
+
});
|
|
1907
1912
|
}
|
|
1908
1913
|
});
|
|
1909
1914
|
}
|
|
1910
1915
|
let returnVal = funToWrap.apply(this, args);
|
|
1911
|
-
|
|
1912
|
-
|
|
1916
|
+
const potentialReturn = returnVal;
|
|
1917
|
+
if (potentialReturn && typeof potentialReturn.start === "number" && potentialReturn.start > -1 && options && options.inclusive1BasedStart) {
|
|
1918
|
+
returnVal = assign(potentialReturn, {
|
|
1919
|
+
start: potentialReturn.start + 1
|
|
1920
|
+
});
|
|
1913
1921
|
}
|
|
1914
|
-
if (
|
|
1915
|
-
returnVal = assign(
|
|
1922
|
+
if (potentialReturn && typeof potentialReturn.end === "number" && potentialReturn.end > -1 && options && options.inclusive1BasedEnd) {
|
|
1923
|
+
returnVal = assign(potentialReturn, { end: potentialReturn.end + 1 });
|
|
1916
1924
|
}
|
|
1917
1925
|
return returnVal;
|
|
1918
1926
|
};
|
|
@@ -1933,9 +1941,10 @@ var __name = (target, value) => __defProp(target, "name", { value, configurable:
|
|
|
1933
1941
|
}
|
|
1934
1942
|
__name(getRangeLength$1, "getRangeLength$1");
|
|
1935
1943
|
function doesRangeSpanEntireSequence(range, sequenceLength) {
|
|
1936
|
-
if (getRangeLength(range) === sequenceLength) {
|
|
1944
|
+
if (getRangeLength(range, sequenceLength) === sequenceLength) {
|
|
1937
1945
|
return true;
|
|
1938
1946
|
}
|
|
1947
|
+
return false;
|
|
1939
1948
|
}
|
|
1940
1949
|
__name(doesRangeSpanEntireSequence, "doesRangeSpanEntireSequence");
|
|
1941
1950
|
function isRangeWithinRange(rangeToCheck, containingRange, maxLength) {
|
|
@@ -1969,6 +1978,9 @@ var __name = (target, value) => __defProp(target, "name", { value, configurable:
|
|
|
1969
1978
|
return false;
|
|
1970
1979
|
}
|
|
1971
1980
|
if (isObject(rangeOrPositionToCheck)) {
|
|
1981
|
+
if (typeof rangeOrPositionToCheck.start !== "number") {
|
|
1982
|
+
return false;
|
|
1983
|
+
}
|
|
1972
1984
|
return isRangeWithinRange(
|
|
1973
1985
|
rangeOrPositionToCheck,
|
|
1974
1986
|
containingRange,
|
|
@@ -1989,7 +2001,7 @@ var __name = (target, value) => __defProp(target, "name", { value, configurable:
|
|
|
1989
2001
|
return range.start > range.end;
|
|
1990
2002
|
}
|
|
1991
2003
|
__name(doesRangeSpanOrigin, "doesRangeSpanOrigin");
|
|
1992
|
-
function normalizePositionByRangeLength(pPosition, sequenceLength, isInBetweenPositions) {
|
|
2004
|
+
function normalizePositionByRangeLength(pPosition, sequenceLength, isInBetweenPositions = false) {
|
|
1993
2005
|
let position = pPosition;
|
|
1994
2006
|
if (position < 0) {
|
|
1995
2007
|
position += sequenceLength;
|
|
@@ -2081,10 +2093,7 @@ var __name = (target, value) => __defProp(target, "name", { value, configurable:
|
|
|
2081
2093
|
if (range.start > range.end) {
|
|
2082
2094
|
return expandOrContractCircularRangeToPosition(range, position, maxLength);
|
|
2083
2095
|
} else {
|
|
2084
|
-
return expandOrContractNonCircularRangeToPosition(
|
|
2085
|
-
range,
|
|
2086
|
-
position
|
|
2087
|
-
);
|
|
2096
|
+
return expandOrContractNonCircularRangeToPosition(range, position);
|
|
2088
2097
|
}
|
|
2089
2098
|
}
|
|
2090
2099
|
__name(expandOrContractRangeToPosition, "expandOrContractRangeToPosition");
|
|
@@ -2342,15 +2351,19 @@ var __name = (target, value) => __defProp(target, "name", { value, configurable:
|
|
|
2342
2351
|
}
|
|
2343
2352
|
__name(getRangesBetweenTwoRanges, "getRangesBetweenTwoRanges");
|
|
2344
2353
|
function getSequenceWithinRange(range, sequence) {
|
|
2345
|
-
if (range.start < 0 || range.end < 0)
|
|
2354
|
+
if (range.start < 0 || range.end < 0) {
|
|
2355
|
+
if (typeof sequence === "string") return "";
|
|
2356
|
+
return [];
|
|
2357
|
+
}
|
|
2346
2358
|
if (range.start > range.end) {
|
|
2347
|
-
|
|
2359
|
+
const subSequence = sequence.slice(range.start, sequence.length);
|
|
2348
2360
|
if (typeof subSequence === "string") {
|
|
2349
|
-
subSequence
|
|
2361
|
+
return subSequence + sequence.slice(0, range.end + 1);
|
|
2350
2362
|
} else {
|
|
2351
|
-
|
|
2363
|
+
return subSequence.concat(
|
|
2364
|
+
sequence.slice(0, range.end + 1)
|
|
2365
|
+
);
|
|
2352
2366
|
}
|
|
2353
|
-
return subSequence;
|
|
2354
2367
|
} else {
|
|
2355
2368
|
return sequence.slice(range.start, range.end + 1);
|
|
2356
2369
|
}
|
|
@@ -2368,7 +2381,7 @@ var __name = (target, value) => __defProp(target, "name", { value, configurable:
|
|
|
2368
2381
|
}
|
|
2369
2382
|
__name(getShortestDistanceBetweenTwoPositions, "getShortestDistanceBetweenTwoPositions");
|
|
2370
2383
|
function getYOffsetForPotentiallyCircularRange(range, YOffsetLevelsWithRanges, assignYOffsetToRange) {
|
|
2371
|
-
let yOffset =
|
|
2384
|
+
let yOffset = 0;
|
|
2372
2385
|
const openYOffsetFound = YOffsetLevelsWithRanges.some(
|
|
2373
2386
|
function(rangesAlreadyAddedToYOffset, index) {
|
|
2374
2387
|
const rangeBlocked = rangesAlreadyAddedToYOffset.some(
|
|
@@ -2418,21 +2431,20 @@ var __name = (target, value) => __defProp(target, "name", { value, configurable:
|
|
|
2418
2431
|
__name(getYOffsetsForPotentiallyCircularRanges, "getYOffsetsForPotentiallyCircularRanges");
|
|
2419
2432
|
const invertRange = provideInclusiveOptions(invertRange$1);
|
|
2420
2433
|
function invertRange$1(rangeOrCaret, rangeMax) {
|
|
2421
|
-
if (rangeOrCaret.start > -1) {
|
|
2434
|
+
if (typeof rangeOrCaret !== "number" && rangeOrCaret.start > -1) {
|
|
2422
2435
|
const start = rangeOrCaret.end + 1;
|
|
2423
2436
|
const end = rangeOrCaret.start - 1;
|
|
2424
2437
|
return {
|
|
2425
2438
|
start: normalizePositionByRangeLength(start, rangeMax, false),
|
|
2426
2439
|
end: normalizePositionByRangeLength(end, rangeMax, false)
|
|
2427
2440
|
};
|
|
2428
|
-
} else {
|
|
2429
|
-
|
|
2430
|
-
|
|
2431
|
-
|
|
2432
|
-
|
|
2433
|
-
};
|
|
2434
|
-
}
|
|
2441
|
+
} else if (typeof rangeOrCaret === "number" && rangeOrCaret > -1) {
|
|
2442
|
+
return {
|
|
2443
|
+
start: normalizePositionByRangeLength(rangeOrCaret, rangeMax, false),
|
|
2444
|
+
end: normalizePositionByRangeLength(rangeOrCaret - 1, rangeMax, false)
|
|
2445
|
+
};
|
|
2435
2446
|
}
|
|
2447
|
+
return void 0;
|
|
2436
2448
|
}
|
|
2437
2449
|
__name(invertRange$1, "invertRange$1");
|
|
2438
2450
|
function isPositionCloserToRangeStartThanRangeEnd(position, range, maxLength) {
|
|
@@ -2500,9 +2512,10 @@ var __name = (target, value) => __defProp(target, "name", { value, configurable:
|
|
|
2500
2512
|
"subRange must be fully contained by containerRange! Otherwise this function does not make sense"
|
|
2501
2513
|
);
|
|
2502
2514
|
}
|
|
2503
|
-
const newSubrange = {
|
|
2504
|
-
|
|
2505
|
-
|
|
2515
|
+
const newSubrange = {
|
|
2516
|
+
start: subRange.start - containerRange.start,
|
|
2517
|
+
end: subRange.end - containerRange.start
|
|
2518
|
+
};
|
|
2506
2519
|
if (newSubrange.start < 0) {
|
|
2507
2520
|
newSubrange.start += sequenceLength;
|
|
2508
2521
|
}
|
|
@@ -2513,10 +2526,10 @@ var __name = (target, value) => __defProp(target, "name", { value, configurable:
|
|
|
2513
2526
|
}
|
|
2514
2527
|
__name(zeroSubrangeByContainerRange, "zeroSubrangeByContainerRange");
|
|
2515
2528
|
function adjustRangeToRotation(rangeToBeAdjusted, rotateTo = 0, rangeLength) {
|
|
2516
|
-
const mod = rangeLength ? modulo :
|
|
2529
|
+
const mod = /* @__PURE__ */ __name((n) => rangeLength ? modulo(n, rangeLength) : n, "mod");
|
|
2517
2530
|
const newRange = assign({}, rangeToBeAdjusted, {
|
|
2518
|
-
start: mod(rangeToBeAdjusted.start - (rotateTo || 0)
|
|
2519
|
-
end: mod(rangeToBeAdjusted.end - (rotateTo || 0)
|
|
2531
|
+
start: mod(rangeToBeAdjusted.start - (rotateTo || 0)),
|
|
2532
|
+
end: mod(rangeToBeAdjusted.end - (rotateTo || 0))
|
|
2520
2533
|
});
|
|
2521
2534
|
return newRange;
|
|
2522
2535
|
}
|
package/invertRange.d.ts
CHANGED
|
@@ -1,2 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
import { Range } from './types';
|
|
2
|
+
declare const _default: (rangeOrCaret: number | Range, rangeMax: number, options?: {
|
|
3
|
+
inclusive1BasedEnd?: boolean;
|
|
4
|
+
inclusive1BasedStart?: boolean;
|
|
5
|
+
} | undefined) => Range | undefined;
|
|
2
6
|
export default _default;
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
import { Range } from './types';
|
|
2
|
+
export default function isPositionCloserToRangeStartThanRangeEnd(position: number, range: Range, maxLength: number): boolean;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
import { Range } from './types';
|
|
2
2
|
/**
|
|
3
3
|
*
|
|
4
4
|
* @param {*} position //assumed to be a 0 based "caretPosition"
|
|
@@ -6,4 +6,5 @@ export default isPositionWithinRange;
|
|
|
6
6
|
* @param {*} sequenceLength
|
|
7
7
|
* @param {*} includeEdges - (default false) whether or not to say
|
|
8
8
|
*/
|
|
9
|
-
declare function isPositionWithinRange(position:
|
|
9
|
+
declare function isPositionWithinRange(position: number, range: Range, sequenceLength: number, includeStartEdge?: boolean, includeEndEdge?: boolean): boolean;
|
|
10
|
+
export default isPositionWithinRange;
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
import { Range } from './types';
|
|
2
|
+
export default function isRangeOrPositionWithinRange(rangeOrPositionToCheck: Range | number, containingRange: Range, maxLength: number, includeStartEdge?: boolean, includeEndEdge?: boolean): boolean;
|
package/isRangeWithinRange.d.ts
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
import { Range } from './types';
|
|
2
|
+
export default function isRangeWithinRange(rangeToCheck: Range, containingRange: Range, maxLength: number): boolean;
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
import { Range } from './types';
|
|
2
|
+
export default function loopEachPositionInRange(range: Range, rangeMax: number, func: (pos: number) => void): void;
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
import { Range } from './types';
|
|
2
|
+
export default function modulatePositionByRange(position: number, range: Range): number;
|
|
@@ -1,2 +1,9 @@
|
|
|
1
|
-
|
|
1
|
+
import { Range } from './types';
|
|
2
|
+
declare const _default: (range: Range, seqLen: number, options?: {
|
|
3
|
+
inclusive1BasedEnd?: boolean;
|
|
4
|
+
inclusive1BasedStart?: boolean;
|
|
5
|
+
} | undefined) => Range & {
|
|
6
|
+
start: number;
|
|
7
|
+
end: number;
|
|
8
|
+
};
|
|
2
9
|
export default _default;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export default function normalizePositionByRangeLength(pPosition:
|
|
1
|
+
export default function normalizePositionByRangeLength(pPosition: number, sequenceLength: number, isInBetweenPositions?: boolean): number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export default function normalizePositionByRangeLength1Based(position:
|
|
1
|
+
export default function normalizePositionByRangeLength1Based(position: number, sequenceLength: number): number;
|
package/normalizeRange.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,9 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@teselagen/range-utils",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.20-beta.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"repository": "https://github.com/TeselaGen/tg-oss",
|
|
6
6
|
"dependencies": {
|
|
7
7
|
"lodash-es": "^4.17.21"
|
|
8
|
-
}
|
|
8
|
+
},
|
|
9
|
+
"main": "./src/index.ts",
|
|
10
|
+
"exports": {
|
|
11
|
+
".": {
|
|
12
|
+
"import": "./src/index.ts",
|
|
13
|
+
"require": "./src/index.ts"
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
"types": "./src/index.ts"
|
|
9
17
|
}
|
|
@@ -1 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
type Options = {
|
|
2
|
+
inclusive1BasedEnd?: boolean;
|
|
3
|
+
inclusive1BasedStart?: boolean;
|
|
4
|
+
};
|
|
5
|
+
export default function provideInclusiveOptions<T extends (...args: any[]) => any>(funToWrap: T): (...args: [...Parameters<T>, options?: Options]) => ReturnType<T>;
|
|
6
|
+
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export default function reversePositionInRange(position:
|
|
1
|
+
export default function reversePositionInRange(position: number, rangeLength: number, isInBetweenPositions: boolean): number;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import { Range } from './types';
|
|
2
|
+
export default function splitRangeIntoTwoPartsIfItIsCircular(range: Range, sequenceLength: number): {
|
|
3
|
+
start: number;
|
|
4
|
+
end: number;
|
|
4
5
|
type: string;
|
|
5
6
|
}[];
|
package/src/{adjustRangeToDeletionOfAnotherRange.js → adjustRangeToDeletionOfAnotherRange.ts}
RENAMED
|
@@ -1,17 +1,14 @@
|
|
|
1
|
+
import { Range } from "./types";
|
|
1
2
|
import splitRangeIntoTwoPartsIfItIsCircular from "./splitRangeIntoTwoPartsIfItIsCircular";
|
|
2
3
|
import trimRangeByAnotherRange from "./trimRangeByAnotherRange";
|
|
3
4
|
|
|
4
5
|
//takes in two potentially circular ranges and returns the first one trimmed by the second one
|
|
5
6
|
//returns null if no range is left after the trimming
|
|
6
7
|
export default function adjustRangeToDeletionOfAnotherRange(
|
|
7
|
-
rangeToBeAdjusted,
|
|
8
|
-
anotherRange,
|
|
9
|
-
maxLength
|
|
8
|
+
rangeToBeAdjusted: Range,
|
|
9
|
+
anotherRange: Range,
|
|
10
|
+
maxLength: number
|
|
10
11
|
) {
|
|
11
|
-
// ac.throw(ac.range, rangeToBeAdjusted)
|
|
12
|
-
// ac.throw(ac.range, anotherRange)
|
|
13
|
-
// ac.throw(ac.posInt, maxLength)
|
|
14
|
-
|
|
15
12
|
const trimmedRange = trimRangeByAnotherRange(
|
|
16
13
|
rangeToBeAdjusted,
|
|
17
14
|
anotherRange,
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { assign } from "lodash-es";
|
|
2
|
+
import { Range } from "./types";
|
|
2
3
|
|
|
3
4
|
export default function adjustRangeToInsert(
|
|
4
|
-
rangeToBeAdjusted,
|
|
5
|
-
insertStart,
|
|
6
|
-
insertLength
|
|
5
|
+
rangeToBeAdjusted: Range,
|
|
6
|
+
insertStart: number,
|
|
7
|
+
insertLength: number
|
|
7
8
|
) {
|
|
8
|
-
// ac.throw([ac.range, ac.posInt, ac.posInt], arguments);
|
|
9
9
|
const newRange = assign({}, rangeToBeAdjusted);
|
|
10
10
|
if (rangeToBeAdjusted.start > rangeToBeAdjusted.end) {
|
|
11
11
|
//circular range
|