@teselagen/range-utils 0.3.8 → 0.3.10

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/package.json CHANGED
@@ -1,8 +1,9 @@
1
1
  {
2
2
  "name": "@teselagen/range-utils",
3
- "version": "0.3.8",
3
+ "version": "0.3.10",
4
+ "type": "module",
4
5
  "dependencies": {
5
- "lodash": "^4.17.21"
6
+ "lodash-es": "^4.17.21"
6
7
  },
7
8
  "license": "MIT"
8
9
  }
@@ -1,4 +1,4 @@
1
- import { assign } from "lodash";
1
+ import { assign } from "lodash-es";
2
2
 
3
3
  export default function adjustRangeToInsert(
4
4
  rangeToBeAdjusted,
@@ -1,6 +1,6 @@
1
- import { assign } from "lodash";
1
+ import { assign } from "lodash-es";
2
2
 
3
- import { identity } from "lodash";
3
+ import { identity } from "lodash-es";
4
4
 
5
5
  export default function adjustRangeToRotation(
6
6
  rangeToBeAdjusted,
@@ -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
- ? 1
15
- : 0),
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
- ? 1
24
- : 0)
23
+ ? 1
24
+ : 0)
25
25
  });
26
26
  }
@@ -1,5 +1,5 @@
1
1
  import normalizePositionByRangeLength from "./normalizePositionByRangeLength";
2
- import { assign } from "lodash";
2
+ import { assign } from "lodash-es";
3
3
 
4
4
  export default function expandOrContractCircularRangeToPosition(
5
5
  range,
@@ -1,4 +1,4 @@
1
- import { assign } from "lodash";
1
+ import { assign } from "lodash-es";
2
2
 
3
3
  export default function expandOrContractNonCircularRangeToPosition(
4
4
  range,
@@ -1,4 +1,4 @@
1
- import { clone } from "lodash";
1
+ import { clone } from "lodash-es";
2
2
  import normalizeRange from "./normalizeRange";
3
3
 
4
4
  export default function expandOrContractRangeByLength(
@@ -1,4 +1,4 @@
1
- import { flatMap } from "lodash";
1
+ import { flatMap } from "lodash-es";
2
2
  import splitRangeIntoTwoPartsIfItIsCircular from "./splitRangeIntoTwoPartsIfItIsCircular";
3
3
  import getOverlapOfNonCircularRanges from "./getOverlapOfNonCircularRanges";
4
4
 
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,4 +1,4 @@
1
- import { isObject } from "lodash";
1
+ import { isObject } from "lodash-es";
2
2
  import isRangeWithinRange from "./isRangeWithinRange";
3
3
  import isPositionWithinRange from "./isPositionWithinRange";
4
4
 
@@ -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) {
@@ -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
 
@@ -1,4 +1,4 @@
1
- import { assign } from "lodash";
1
+ import { assign } from "lodash-es";
2
2
 
3
3
  export default function provideInclusiveOptions(funToWrap) {
4
4
  return function () {
@@ -1,4 +1,4 @@
1
- import { assign } from "lodash";
1
+ import { assign } from "lodash-es";
2
2
  import normalizePositionByRangeLength from "./normalizePositionByRangeLength";
3
3
 
4
4
  export default function translateRange(
@@ -0,0 +1,9 @@
1
+ export default function trimAnnStartEndToFitSeqLength(
2
+ annStartOrEnd,
3
+ sequenceLength
4
+ ) {
5
+ return Math.max(
6
+ 0,
7
+ Math.min(annStartOrEnd || 0, Math.max(sequenceLength - 1, 0))
8
+ );
9
+ }
@@ -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 {};