@teselagen/range-utils 0.3.8 → 0.3.9
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/index.cjs +2619 -0
- package/index.d.ts +52 -51
- package/index.js +1560 -6017
- package/index.umd.cjs +2623 -0
- package/package.json +2 -2
- package/src/adjustRangeToInsert.js +1 -1
- package/src/adjustRangeToRotation.js +2 -2
- package/src/convertRangeIndices.js +5 -5
- package/src/expandOrContractCircularRangeToPosition.js +1 -1
- package/src/expandOrContractNonCircularRangeToPosition.js +1 -1
- package/src/expandOrContractRangeByLength.js +1 -1
- package/src/getOverlapsOfPotentiallyCircularRanges.js +1 -1
- package/src/index.js +1 -0
- package/src/isRangeOrPositionWithinRange.js +1 -1
- package/src/modulateRangeBySequenceLength.js +1 -1
- package/src/normalizeRange.js +1 -1
- package/src/provideInclusiveOptions.js +1 -1
- package/src/translateRange.js +1 -1
- package/src/trimAnnStartEndToFitSeqLength.js +9 -0
- package/src/trimAnnStartEndToFitSeqLength.test.js +35 -0
- package/src/trimRangeByAnotherRange.js +1 -1
- package/trimAnnStartEndToFitSeqLength.d.ts +1 -0
- package/trimAnnStartEndToFitSeqLength.test.d.ts +1 -0
- package/index.mjs +0 -7076
- package/index.umd.js +0 -7080
package/package.json
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
import { assign } from "lodash";
|
1
|
+
import { assign } from "lodash-es";
|
2
2
|
|
3
3
|
export default function convertRangeIndices(range, inputType, outputType) {
|
4
4
|
inputType = inputType || {};
|
@@ -11,8 +11,8 @@ export default function convertRangeIndices(range, inputType, outputType) {
|
|
11
11
|
? 0
|
12
12
|
: -1
|
13
13
|
: outputType.inclusive1BasedStart
|
14
|
-
|
15
|
-
|
14
|
+
? 1
|
15
|
+
: 0),
|
16
16
|
end:
|
17
17
|
Number(range.end) +
|
18
18
|
(inputType.inclusive1BasedEnd
|
@@ -20,7 +20,7 @@ export default function convertRangeIndices(range, inputType, outputType) {
|
|
20
20
|
? 0
|
21
21
|
: -1
|
22
22
|
: outputType.inclusive1BasedEnd
|
23
|
-
|
24
|
-
|
23
|
+
? 1
|
24
|
+
: 0)
|
25
25
|
});
|
26
26
|
}
|
package/src/index.js
CHANGED
@@ -49,3 +49,4 @@ export { default as trimRangeByAnotherRange } from "./trimRangeByAnotherRange";
|
|
49
49
|
export { default as zeroSubrangeByContainerRange } from "./zeroSubrangeByContainerRange";
|
50
50
|
export { default as adjustRangeToRotation } from "./adjustRangeToRotation";
|
51
51
|
export { default as getZeroedRangeOverlaps } from "./getZeroedRangeOverlaps";
|
52
|
+
export { default as trimAnnStartEndToFitSeqLength } from "./trimAnnStartEndToFitSeqLength";
|
@@ -1,6 +1,6 @@
|
|
1
1
|
import normalizePositionByRangeLength from "./normalizePositionByRangeLength";
|
2
2
|
import provideInclusiveOptions from "./provideInclusiveOptions";
|
3
|
-
import { assign } from "lodash";
|
3
|
+
import { assign } from "lodash-es";
|
4
4
|
export default provideInclusiveOptions(modulateRangeBySequenceLength);
|
5
5
|
|
6
6
|
function modulateRangeBySequenceLength(range, seqLen) {
|
package/src/normalizeRange.js
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
//normalize range takes in a range that might be slightly outside of the rangeMax and wraps the start/end as necessary to fit
|
2
|
-
import { assign } from "lodash";
|
2
|
+
import { assign } from "lodash-es";
|
3
3
|
|
4
4
|
import normalizePositionByRangeLength from "./normalizePositionByRangeLength";
|
5
5
|
|
package/src/translateRange.js
CHANGED
@@ -0,0 +1,35 @@
|
|
1
|
+
import trimAnnStartEndToFitSeqLength from './trimAnnStartEndToFitSeqLength';
|
2
|
+
|
3
|
+
describe('trimAnnStartEndToFitSeqLength', () => {
|
4
|
+
test('should return 0 if annStartOrEnd is undefined', () => {
|
5
|
+
expect(trimAnnStartEndToFitSeqLength(undefined, 10)).toBe(0);
|
6
|
+
});
|
7
|
+
|
8
|
+
test('should return 0 if annStartOrEnd is null', () => {
|
9
|
+
expect(trimAnnStartEndToFitSeqLength(null, 10)).toBe(0);
|
10
|
+
});
|
11
|
+
|
12
|
+
test('should return 0 if annStartOrEnd is less than 0', () => {
|
13
|
+
expect(trimAnnStartEndToFitSeqLength(-5, 10)).toBe(0);
|
14
|
+
});
|
15
|
+
|
16
|
+
test('should return annStartOrEnd if it is within the sequence length', () => {
|
17
|
+
expect(trimAnnStartEndToFitSeqLength(5, 10)).toBe(5);
|
18
|
+
});
|
19
|
+
|
20
|
+
test('should return sequenceLength - 1 if annStartOrEnd is greater than sequenceLength', () => {
|
21
|
+
expect(trimAnnStartEndToFitSeqLength(15, 10)).toBe(9);
|
22
|
+
});
|
23
|
+
|
24
|
+
test('should return 0 if sequenceLength is 0', () => {
|
25
|
+
expect(trimAnnStartEndToFitSeqLength(5, 0)).toBe(0);
|
26
|
+
});
|
27
|
+
|
28
|
+
test('should return 0 if sequenceLength is negative', () => {
|
29
|
+
expect(trimAnnStartEndToFitSeqLength(5, -10)).toBe(0);
|
30
|
+
});
|
31
|
+
|
32
|
+
test('should return 0 if annStartOrEnd is 0', () => {
|
33
|
+
expect(trimAnnStartEndToFitSeqLength(0, 10)).toBe(0);
|
34
|
+
});
|
35
|
+
});
|
@@ -1,7 +1,7 @@
|
|
1
1
|
import getOverlapsOfPotentiallyCircularRanges from "./getOverlapsOfPotentiallyCircularRanges";
|
2
2
|
import splitRangeIntoTwoPartsIfItIsCircular from "./splitRangeIntoTwoPartsIfItIsCircular";
|
3
3
|
import trimNonCicularRangeByAnotherNonCircularRange from "./trimNonCicularRangeByAnotherNonCircularRange";
|
4
|
-
import { extend } from "lodash";
|
4
|
+
import { extend } from "lodash-es";
|
5
5
|
|
6
6
|
/**
|
7
7
|
* trims range, but does *not* adjust it
|
@@ -0,0 +1 @@
|
|
1
|
+
export default function trimAnnStartEndToFitSeqLength(annStartOrEnd: any, sequenceLength: any): number;
|
@@ -0,0 +1 @@
|
|
1
|
+
export {};
|