@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.
- package/README.md +94 -0
- package/flipContainedRange.d.ts +1 -1
- package/index.cjs +2619 -0
- package/index.d.ts +52 -51
- package/index.js +1791 -6100
- package/index.umd.cjs +2623 -0
- package/package.json +2 -3
- package/src/adjustRangeToDeletionOfAnotherRange.test.js +166 -105
- package/src/adjustRangeToInsert.js +29 -26
- package/src/adjustRangeToInsert.test.js +197 -109
- package/src/adjustRangeToRotation.js +4 -5
- package/src/adjustRangeToRotation.test.js +203 -119
- package/src/checkIfNonCircularRangesOverlap.js +18 -15
- package/src/checkIfNonCircularRangesOverlap.test.js +67 -42
- package/src/checkIfPotentiallyCircularRangesOverlap.js +22 -12
- package/src/checkIfPotentiallyCircularRangesOverlap.test.js +115 -70
- package/src/collapseOverlapsGeneratedFromRangeComparisonIfPossible.js +72 -41
- package/src/collapseOverlapsGeneratedFromRangeComparisonIfPossible.test.js +183 -84
- package/src/convertRangeIndices.js +24 -20
- package/src/convertRangeIndices.test.js +40 -21
- package/src/convertRangeTo0Based.js +7 -4
- package/src/convertRangeTo1Based.js +8 -4
- package/src/doesRangeSpanEntireSequence.js +4 -4
- package/src/doesRangeSpanOrigin.js +3 -3
- package/src/expandOrContractCircularRangeToPosition.js +45 -38
- package/src/expandOrContractNonCircularRangeToPosition.js +24 -21
- package/src/expandOrContractRangeByLength.js +16 -11
- package/src/expandOrContractRangeByLength.test.js +109 -71
- package/src/expandOrContractRangeToPosition.js +17 -9
- package/src/flipContainedRange.js +133 -72
- package/src/flipContainedRange.test.js +143 -117
- package/src/generateRandomRange.js +17 -15
- package/src/generateRandomRange.test.js +21 -21
- package/src/getAnnotationRangeType.js +25 -21
- package/src/getAnnotationRangeType.test.js +56 -57
- package/src/getEachPositionInRangeAsArray.js +13 -13
- package/src/getEachPositionInRangeAsArray.test.js +12 -8
- package/src/getLengthOfOverlappingRegionsBetweenTwoRanges.js +16 -8
- package/src/getLengthOfOverlappingRegionsBetweenTwoRanges.test.js +32 -24
- package/src/getMiddleOfRange.js +1 -1
- package/src/getMiddleOfRange.test.js +5 -13
- package/src/getOverlapOfNonCircularRanges.js +30 -30
- package/src/getOverlapsOfPotentiallyCircularRanges.js +5 -5
- package/src/getOverlapsOfPotentiallyCircularRanges.test.js +3 -23
- package/src/getPositionFromAngle.js +12 -7
- package/src/getRangeAngles.js +1 -1
- package/src/getRangeAngles.test.js +10 -11
- package/src/getRangeLength.test.js +5 -5
- package/src/getRangesBetweenTwoRanges.js +31 -22
- package/src/getSequenceWithinRange.js +13 -13
- package/src/getSequenceWithinRange.test.js +43 -45
- package/src/getShortestDistanceBetweenTwoPositions.js +10 -6
- package/src/getShortestDistanceBetweenTwoPositions.test.js +11 -13
- package/src/getYOffsetForPotentiallyCircularRange.js +33 -21
- package/src/getYOffsetsForPotentiallyCircularRanges.js +26 -19
- package/src/getYOffsetsForPotentiallyCircularRanges.test.js +42 -29
- package/src/getZeroedRangeOverlaps.js +30 -15
- package/src/getZeroedRangeOverlaps.test.js +75 -36
- package/src/index.js +52 -51
- package/src/index.test.js +6 -8
- package/src/invertRange.test.js +103 -93
- package/src/isPositionCloserToRangeStartThanRangeEnd.js +18 -6
- package/src/isPositionCloserToRangeStartThanRangeEnd.test.js +36 -16
- package/src/isPositionWithinRange.js +4 -4
- package/src/isRangeOrPositionWithinRange.js +18 -12
- package/src/isRangeOrPositionWithinRange.test.js +6 -6
- package/src/isRangeWithinRange.js +2 -3
- package/src/loopEachPositionInRange.js +3 -3
- package/src/modulatePositionByRange.js +8 -8
- package/src/modulatePositionByRange.test.js +10 -11
- package/src/modulateRangeBySequenceLength.js +7 -7
- package/src/modulateRangeBySequenceLength.test.js +39 -16
- package/src/normalizePositionByRangeLength.js +22 -18
- package/src/normalizePositionByRangeLength.test.js +23 -23
- package/src/normalizePositionByRangeLength1Based.js +7 -4
- package/src/normalizePositionByRangeLength1Based.test.js +9 -9
- package/src/normalizeRange.js +7 -7
- package/src/normalizeRange.test.js +9 -9
- package/src/provideInclusiveOptions.js +36 -23
- package/src/reversePositionInRange.js +16 -12
- package/src/splitRangeIntoTwoPartsIfItIsCircular.js +31 -28
- package/src/splitRangeIntoTwoPartsIfItIsCircular.test.js +22 -11
- package/src/translateRange.js +18 -8
- package/src/translateRange.test.js +18 -19
- package/src/trimAnnStartEndToFitSeqLength.js +9 -0
- package/src/trimAnnStartEndToFitSeqLength.test.js +35 -0
- package/src/trimNonCicularRangeByAnotherNonCircularRange.js +45 -42
- package/src/trimNumberToFitWithin0ToAnotherNumber.js +13 -10
- package/src/trimRangeByAnotherRange.js +20 -19
- package/src/trimRangeByAnotherRange.test.js +6 -6
- package/src/zeroSubrangeByContainerRange.js +29 -19
- package/src/zeroSubrangeByContainerRange.test.js +57 -47
- package/trimAnnStartEndToFitSeqLength.d.ts +1 -0
- package/trimAnnStartEndToFitSeqLength.test.d.ts +1 -0
- package/index.mjs +0 -6928
- 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).
|
package/flipContainedRange.d.ts
CHANGED
@@ -1 +1 @@
|
|
1
|
-
export default function flipRelativeRange(innerRange: any, outerRange: any, sequenceLength: any
|
1
|
+
export default function flipRelativeRange(innerRange: any, outerRange: any, sequenceLength: any): any;
|