@teselagen/range-utils 0.3.7 → 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.
Files changed (96) hide show
  1. package/README.md +94 -0
  2. package/flipContainedRange.d.ts +1 -1
  3. package/index.cjs +2619 -0
  4. package/index.d.ts +52 -51
  5. package/index.js +1791 -6100
  6. package/index.umd.cjs +2623 -0
  7. package/package.json +2 -3
  8. package/src/adjustRangeToDeletionOfAnotherRange.test.js +166 -105
  9. package/src/adjustRangeToInsert.js +29 -26
  10. package/src/adjustRangeToInsert.test.js +197 -109
  11. package/src/adjustRangeToRotation.js +4 -5
  12. package/src/adjustRangeToRotation.test.js +203 -119
  13. package/src/checkIfNonCircularRangesOverlap.js +18 -15
  14. package/src/checkIfNonCircularRangesOverlap.test.js +67 -42
  15. package/src/checkIfPotentiallyCircularRangesOverlap.js +22 -12
  16. package/src/checkIfPotentiallyCircularRangesOverlap.test.js +115 -70
  17. package/src/collapseOverlapsGeneratedFromRangeComparisonIfPossible.js +72 -41
  18. package/src/collapseOverlapsGeneratedFromRangeComparisonIfPossible.test.js +183 -84
  19. package/src/convertRangeIndices.js +24 -20
  20. package/src/convertRangeIndices.test.js +40 -21
  21. package/src/convertRangeTo0Based.js +7 -4
  22. package/src/convertRangeTo1Based.js +8 -4
  23. package/src/doesRangeSpanEntireSequence.js +4 -4
  24. package/src/doesRangeSpanOrigin.js +3 -3
  25. package/src/expandOrContractCircularRangeToPosition.js +45 -38
  26. package/src/expandOrContractNonCircularRangeToPosition.js +24 -21
  27. package/src/expandOrContractRangeByLength.js +16 -11
  28. package/src/expandOrContractRangeByLength.test.js +109 -71
  29. package/src/expandOrContractRangeToPosition.js +17 -9
  30. package/src/flipContainedRange.js +133 -72
  31. package/src/flipContainedRange.test.js +143 -117
  32. package/src/generateRandomRange.js +17 -15
  33. package/src/generateRandomRange.test.js +21 -21
  34. package/src/getAnnotationRangeType.js +25 -21
  35. package/src/getAnnotationRangeType.test.js +56 -57
  36. package/src/getEachPositionInRangeAsArray.js +13 -13
  37. package/src/getEachPositionInRangeAsArray.test.js +12 -8
  38. package/src/getLengthOfOverlappingRegionsBetweenTwoRanges.js +16 -8
  39. package/src/getLengthOfOverlappingRegionsBetweenTwoRanges.test.js +32 -24
  40. package/src/getMiddleOfRange.js +1 -1
  41. package/src/getMiddleOfRange.test.js +5 -13
  42. package/src/getOverlapOfNonCircularRanges.js +30 -30
  43. package/src/getOverlapsOfPotentiallyCircularRanges.js +5 -5
  44. package/src/getOverlapsOfPotentiallyCircularRanges.test.js +3 -23
  45. package/src/getPositionFromAngle.js +12 -7
  46. package/src/getRangeAngles.js +1 -1
  47. package/src/getRangeAngles.test.js +10 -11
  48. package/src/getRangeLength.test.js +5 -5
  49. package/src/getRangesBetweenTwoRanges.js +31 -22
  50. package/src/getSequenceWithinRange.js +13 -13
  51. package/src/getSequenceWithinRange.test.js +43 -45
  52. package/src/getShortestDistanceBetweenTwoPositions.js +10 -6
  53. package/src/getShortestDistanceBetweenTwoPositions.test.js +11 -13
  54. package/src/getYOffsetForPotentiallyCircularRange.js +33 -21
  55. package/src/getYOffsetsForPotentiallyCircularRanges.js +26 -19
  56. package/src/getYOffsetsForPotentiallyCircularRanges.test.js +42 -29
  57. package/src/getZeroedRangeOverlaps.js +30 -15
  58. package/src/getZeroedRangeOverlaps.test.js +75 -36
  59. package/src/index.js +52 -51
  60. package/src/index.test.js +6 -8
  61. package/src/invertRange.test.js +103 -93
  62. package/src/isPositionCloserToRangeStartThanRangeEnd.js +18 -6
  63. package/src/isPositionCloserToRangeStartThanRangeEnd.test.js +36 -16
  64. package/src/isPositionWithinRange.js +4 -4
  65. package/src/isRangeOrPositionWithinRange.js +18 -12
  66. package/src/isRangeOrPositionWithinRange.test.js +6 -6
  67. package/src/isRangeWithinRange.js +2 -3
  68. package/src/loopEachPositionInRange.js +3 -3
  69. package/src/modulatePositionByRange.js +8 -8
  70. package/src/modulatePositionByRange.test.js +10 -11
  71. package/src/modulateRangeBySequenceLength.js +7 -7
  72. package/src/modulateRangeBySequenceLength.test.js +39 -16
  73. package/src/normalizePositionByRangeLength.js +22 -18
  74. package/src/normalizePositionByRangeLength.test.js +23 -23
  75. package/src/normalizePositionByRangeLength1Based.js +7 -4
  76. package/src/normalizePositionByRangeLength1Based.test.js +9 -9
  77. package/src/normalizeRange.js +7 -7
  78. package/src/normalizeRange.test.js +9 -9
  79. package/src/provideInclusiveOptions.js +36 -23
  80. package/src/reversePositionInRange.js +16 -12
  81. package/src/splitRangeIntoTwoPartsIfItIsCircular.js +31 -28
  82. package/src/splitRangeIntoTwoPartsIfItIsCircular.test.js +22 -11
  83. package/src/translateRange.js +18 -8
  84. package/src/translateRange.test.js +18 -19
  85. package/src/trimAnnStartEndToFitSeqLength.js +9 -0
  86. package/src/trimAnnStartEndToFitSeqLength.test.js +35 -0
  87. package/src/trimNonCicularRangeByAnotherNonCircularRange.js +45 -42
  88. package/src/trimNumberToFitWithin0ToAnotherNumber.js +13 -10
  89. package/src/trimRangeByAnotherRange.js +20 -19
  90. package/src/trimRangeByAnotherRange.test.js +6 -6
  91. package/src/zeroSubrangeByContainerRange.js +29 -19
  92. package/src/zeroSubrangeByContainerRange.test.js +57 -47
  93. package/trimAnnStartEndToFitSeqLength.d.ts +1 -0
  94. package/trimAnnStartEndToFitSeqLength.test.d.ts +1 -0
  95. package/index.mjs +0 -6928
  96. package/index.umd.js +0 -6932
package/README.md ADDED
@@ -0,0 +1,94 @@
1
+ <!-- TOC -->
2
+
3
+ - [[CHANGELOG](Changelog.md)](#changelogchangelogmd)
4
+ - [Installing](#installing)
5
+ - [Usage](#usage)
6
+ - [About this Repo](#about-this-repo)
7
+ - [Editing This Repo:](#editing-this-repo)
8
+ - [All collaborators:](#all-collaborators)
9
+ - [Updating this repo:](#updating-this-repo)
10
+ - [Teselagen collaborators:](#teselagen-collaborators)
11
+ - [Outside collaborators:](#outside-collaborators)
12
+ - [Building](#building)
13
+ - [Running unit tests](#running-unit-tests)
14
+
15
+ <!-- /TOC -->
16
+
17
+ ## [CHANGELOG](Changelog.md)
18
+
19
+ ## Installing
20
+
21
+ ```
22
+ npm install @teselagen/range-utils
23
+ ```
24
+
25
+ ## Usage
26
+
27
+ ```
28
+ import { getRangeLength } from '@teselagen/range-utils';
29
+ ```
30
+
31
+ ## About this Repo
32
+
33
+ This is a collection of range utility functions.
34
+
35
+ A range must be an object with a start and end property.
36
+ Eg:
37
+
38
+ ```
39
+ const myRange = {
40
+ start: 10,
41
+ end: 40
42
+ }
43
+ ```
44
+
45
+ A "circular" range has a start > end.
46
+ Eg:
47
+
48
+ ```
49
+ const myRange2 = {
50
+ start: 50,
51
+ end: 40
52
+ }
53
+ ```
54
+
55
+ All ranges are assumed to have 0-based inclusive indices:
56
+
57
+ rrrr
58
+ 0123
59
+ start = 0,
60
+ end = 3
61
+
62
+ ## Editing This Repo:
63
+
64
+ ### All collaborators:
65
+
66
+ Edit/create a new file and update/add any relevant tests.
67
+ You can run `npm test` to make sure all tests pass.
68
+ Tests will automatically be run pre-commit.
69
+
70
+ ## Updating this repo:
71
+
72
+ ### Teselagen collaborators:
73
+
74
+ Commit and push all changes
75
+ Sign into npm using the teselagen npm account (npm whoami)
76
+
77
+ ```
78
+ npm version patch|minor|major
79
+ npm publish
80
+ ```
81
+
82
+ ### Outside collaborators:
83
+
84
+ fork and pull request please :)
85
+
86
+ This library was generated with [Nx](https://nx.dev).
87
+
88
+ ## Building
89
+
90
+ Run `nx build range-utils` to build the library.
91
+
92
+ ## Running unit tests
93
+
94
+ Run `nx test range-utils` to execute the unit tests via [Jest](https://jestjs.io).
@@ -1 +1 @@
1
- export default function flipRelativeRange(innerRange: any, outerRange: any, sequenceLength: any, options: any): any;
1
+ export default function flipRelativeRange(innerRange: any, outerRange: any, sequenceLength: any): any;