@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
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/getRangeAngles.test.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/getRangeLength.test.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/index.test.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/invertRange.test.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/normalizeRange.test.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { assign } from "lodash-es";
|
|
2
|
-
|
|
3
|
-
import { identity } from "lodash-es";
|
|
4
|
-
|
|
5
|
-
export default function adjustRangeToRotation(
|
|
6
|
-
rangeToBeAdjusted,
|
|
7
|
-
rotateTo = 0,
|
|
8
|
-
rangeLength
|
|
9
|
-
) {
|
|
10
|
-
// ac.throw([ac.range, ac.posInt, ac.posInt], arguments);
|
|
11
|
-
const mod = rangeLength ? modulo : identity;
|
|
12
|
-
|
|
13
|
-
const newRange = assign({}, rangeToBeAdjusted, {
|
|
14
|
-
start: mod(rangeToBeAdjusted.start - (rotateTo || 0), rangeLength),
|
|
15
|
-
end: mod(rangeToBeAdjusted.end - (rotateTo || 0), rangeLength)
|
|
16
|
-
});
|
|
17
|
-
|
|
18
|
-
return newRange;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
function modulo(n, m) {
|
|
22
|
-
return ((n % m) + m) % m;
|
|
23
|
-
}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
export default function getSequenceWithinRange(range, sequence) {
|
|
3
|
-
// ac.throw([ac.range, ac.oneOfType([ac.array, ac.string])], arguments);
|
|
4
|
-
if (range.start < 0 || range.end < 0) return "";
|
|
5
|
-
if (range.start > range.end) {
|
|
6
|
-
//circular range
|
|
7
|
-
let subSequence = sequence.slice(range.start, sequence.length);
|
|
8
|
-
if (typeof subSequence === "string") {
|
|
9
|
-
subSequence += sequence.slice(0, range.end + 1);
|
|
10
|
-
} else {
|
|
11
|
-
subSequence = subSequence.concat(sequence.slice(0, range.end + 1));
|
|
12
|
-
}
|
|
13
|
-
return subSequence;
|
|
14
|
-
} else {
|
|
15
|
-
return sequence.slice(range.start, range.end + 1);
|
|
16
|
-
}
|
|
17
|
-
}
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import { expect } from "chai";
|
|
2
|
-
import getYOffsetsForPotentiallyCircularRanges from "./getYOffsetsForPotentiallyCircularRanges.js";
|
|
3
|
-
describe("getYOffsetsForPotentiallyCircularRanges", function () {
|
|
4
|
-
it("returns correct yOffset for overlapping ranges", function () {
|
|
5
|
-
expect(
|
|
6
|
-
getYOffsetsForPotentiallyCircularRanges([
|
|
7
|
-
{
|
|
8
|
-
start: 5,
|
|
9
|
-
end: 100
|
|
10
|
-
},
|
|
11
|
-
{
|
|
12
|
-
start: 50,
|
|
13
|
-
end: 50
|
|
14
|
-
}
|
|
15
|
-
])
|
|
16
|
-
).to.deep.equal({ yOffsets: [0, 1], maxYOffset: 1 });
|
|
17
|
-
expect(
|
|
18
|
-
getYOffsetsForPotentiallyCircularRanges([
|
|
19
|
-
{
|
|
20
|
-
start: 5,
|
|
21
|
-
end: 100
|
|
22
|
-
},
|
|
23
|
-
{
|
|
24
|
-
start: 50,
|
|
25
|
-
end: 50
|
|
26
|
-
},
|
|
27
|
-
{
|
|
28
|
-
start: 50,
|
|
29
|
-
end: 50
|
|
30
|
-
},
|
|
31
|
-
{
|
|
32
|
-
start: 150,
|
|
33
|
-
end: 4
|
|
34
|
-
},
|
|
35
|
-
{
|
|
36
|
-
start: 150,
|
|
37
|
-
end: 150
|
|
38
|
-
}
|
|
39
|
-
])
|
|
40
|
-
).to.deep.equal({ yOffsets: [0, 1, 2, 0, 1], maxYOffset: 2 });
|
|
41
|
-
});
|
|
42
|
-
});
|
package/src/invertRange.js
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import normalizePositionByRangeLength from "./normalizePositionByRangeLength";
|
|
2
|
-
import provideInclusiveOptions from "./provideInclusiveOptions";
|
|
3
|
-
export default provideInclusiveOptions(invertRange);
|
|
4
|
-
|
|
5
|
-
function invertRange(rangeOrCaret, rangeMax) {
|
|
6
|
-
if (rangeOrCaret.start > -1) {
|
|
7
|
-
const start = rangeOrCaret.end + 1;
|
|
8
|
-
const end = rangeOrCaret.start - 1;
|
|
9
|
-
return {
|
|
10
|
-
start: normalizePositionByRangeLength(start, rangeMax, false),
|
|
11
|
-
end: normalizePositionByRangeLength(end, rangeMax, false)
|
|
12
|
-
};
|
|
13
|
-
} else {
|
|
14
|
-
if (rangeOrCaret > -1) {
|
|
15
|
-
return {
|
|
16
|
-
start: normalizePositionByRangeLength(rangeOrCaret, rangeMax, false),
|
|
17
|
-
end: normalizePositionByRangeLength(rangeOrCaret - 1, rangeMax, false)
|
|
18
|
-
};
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
}
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import { assign } from "lodash-es";
|
|
2
|
-
|
|
3
|
-
export default function provideInclusiveOptions(funToWrap) {
|
|
4
|
-
return function () {
|
|
5
|
-
const args = Array.prototype.slice.call(arguments);
|
|
6
|
-
const options = args[args.length - 1];
|
|
7
|
-
if (
|
|
8
|
-
options &&
|
|
9
|
-
(options.inclusive1BasedEnd || options.inclusive1BasedStart)
|
|
10
|
-
) {
|
|
11
|
-
args.forEach(function (arg, index) {
|
|
12
|
-
if (arg && arg.start > -1 && options.inclusive1BasedStart) {
|
|
13
|
-
args[index] = assign(arg, { start: arg.start - 1 });
|
|
14
|
-
}
|
|
15
|
-
if (arg && arg.end > -1 && options.inclusive1BasedEnd) {
|
|
16
|
-
args[index] = assign(arg, { end: arg.end - 1 });
|
|
17
|
-
}
|
|
18
|
-
});
|
|
19
|
-
}
|
|
20
|
-
let returnVal = funToWrap.apply(this, args);
|
|
21
|
-
if (
|
|
22
|
-
returnVal &&
|
|
23
|
-
returnVal.start > -1 &&
|
|
24
|
-
options &&
|
|
25
|
-
options.inclusive1BasedStart
|
|
26
|
-
) {
|
|
27
|
-
returnVal = assign(returnVal, { start: returnVal.start + 1 });
|
|
28
|
-
}
|
|
29
|
-
if (
|
|
30
|
-
returnVal &&
|
|
31
|
-
returnVal.end > -1 &&
|
|
32
|
-
options &&
|
|
33
|
-
options.inclusive1BasedEnd
|
|
34
|
-
) {
|
|
35
|
-
returnVal = assign(returnVal, { end: returnVal.end + 1 });
|
|
36
|
-
}
|
|
37
|
-
return returnVal;
|
|
38
|
-
};
|
|
39
|
-
}
|
package/translateRange.test.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
File without changes
|
|
File without changes
|
|
File without changes
|