@teselagen/range-utils 0.3.14-beta.3 → 0.3.18

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 (120) hide show
  1. package/adjustRangeToDeletionOfAnotherRange.d.ts +1 -2
  2. package/adjustRangeToInsert.d.ts +1 -2
  3. package/adjustRangeToRotation.d.ts +1 -5
  4. package/checkIfNonCircularRangesOverlap.d.ts +1 -2
  5. package/checkIfPotentiallyCircularRangesOverlap.d.ts +1 -2
  6. package/collapseOverlapsGeneratedFromRangeComparisonIfPossible.d.ts +1 -2
  7. package/convertRangeIndices.d.ts +1 -10
  8. package/convertRangeTo0Based.d.ts +1 -5
  9. package/convertRangeTo1Based.d.ts +1 -5
  10. package/doesRangeSpanEntireSequence.d.ts +1 -2
  11. package/doesRangeSpanOrigin.d.ts +1 -2
  12. package/expandOrContractCircularRangeToPosition.d.ts +2 -3
  13. package/expandOrContractNonCircularRangeToPosition.d.ts +2 -3
  14. package/expandOrContractRangeByLength.d.ts +1 -5
  15. package/expandOrContractRangeToPosition.d.ts +2 -3
  16. package/flipContainedRange.d.ts +1 -5
  17. package/generateRandomRange.d.ts +3 -3
  18. package/getAnnotationRangeType.d.ts +1 -2
  19. package/getEachPositionInRangeAsArray.d.ts +1 -2
  20. package/getLengthOfOverlappingRegionsBetweenTwoRanges.d.ts +1 -2
  21. package/getMiddleOfRange.d.ts +1 -2
  22. package/getOverlapOfNonCircularRanges.d.ts +4 -5
  23. package/getOverlapsOfPotentiallyCircularRanges.d.ts +1 -2
  24. package/getPositionFromAngle.d.ts +1 -1
  25. package/getRangeAngles.d.ts +7 -3
  26. package/getRangeLength.d.ts +1 -5
  27. package/getRangesBetweenTwoRanges.d.ts +1 -2
  28. package/getSequenceWithinRange.d.ts +1 -2
  29. package/getShortestDistanceBetweenTwoPositions.d.ts +1 -1
  30. package/getYOffsetForPotentiallyCircularRange.d.ts +1 -2
  31. package/getYOffsetsForPotentiallyCircularRanges.d.ts +2 -3
  32. package/getZeroedRangeOverlaps.d.ts +1 -2
  33. package/index.cjs +41 -52
  34. package/index.d.ts +0 -1
  35. package/index.js +41 -52
  36. package/index.umd.cjs +41 -52
  37. package/invertRange.d.ts +1 -5
  38. package/isPositionCloserToRangeStartThanRangeEnd.d.ts +1 -2
  39. package/isPositionWithinRange.d.ts +2 -3
  40. package/isRangeOrPositionWithinRange.d.ts +1 -2
  41. package/isRangeWithinRange.d.ts +1 -2
  42. package/loopEachPositionInRange.d.ts +1 -2
  43. package/modulatePositionByRange.d.ts +1 -2
  44. package/modulateRangeBySequenceLength.d.ts +1 -8
  45. package/normalizePositionByRangeLength.d.ts +1 -1
  46. package/normalizePositionByRangeLength1Based.d.ts +1 -1
  47. package/normalizeRange.d.ts +1 -5
  48. package/package.json +4 -12
  49. package/provideInclusiveOptions.d.ts +1 -6
  50. package/reversePositionInRange.d.ts +1 -1
  51. package/splitRangeIntoTwoPartsIfItIsCircular.d.ts +3 -4
  52. package/translateRange.d.ts +1 -5
  53. package/trimAnnStartEndToFitSeqLength.d.ts +1 -1
  54. package/trimNonCicularRangeByAnotherNonCircularRange.d.ts +4 -2
  55. package/trimNumberToFitWithin0ToAnotherNumber.d.ts +1 -1
  56. package/trimRangeByAnotherRange.d.ts +1 -2
  57. package/zeroSubrangeByContainerRange.d.ts +1 -2
  58. package/RangeAngles.d.ts +0 -7
  59. package/src/RangeAngles.ts +0 -9
  60. package/src/adjustRangeToDeletionOfAnotherRange.ts +0 -57
  61. package/src/adjustRangeToInsert.ts +0 -32
  62. package/src/adjustRangeToRotation.ts +0 -23
  63. package/src/checkIfNonCircularRangesOverlap.ts +0 -35
  64. package/src/checkIfPotentiallyCircularRangesOverlap.ts +0 -28
  65. package/src/collapseOverlapsGeneratedFromRangeComparisonIfPossible.ts +0 -81
  66. package/src/convertRangeIndices.ts +0 -34
  67. package/src/convertRangeTo0Based.ts +0 -9
  68. package/src/convertRangeTo1Based.ts +0 -10
  69. package/src/doesRangeSpanEntireSequence.ts +0 -12
  70. package/src/doesRangeSpanOrigin.ts +0 -5
  71. package/src/expandOrContractCircularRangeToPosition.ts +0 -50
  72. package/src/expandOrContractNonCircularRangeToPosition.ts +0 -30
  73. package/src/expandOrContractRangeByLength.ts +0 -18
  74. package/src/expandOrContractRangeToPosition.ts +0 -16
  75. package/src/flipContainedRange.ts +0 -156
  76. package/src/generateRandomRange.ts +0 -26
  77. package/src/getAnnotationRangeType.ts +0 -30
  78. package/src/getEachPositionInRangeAsArray.ts +0 -19
  79. package/src/getLengthOfOverlappingRegionsBetweenTwoRanges.ts +0 -18
  80. package/src/getMiddleOfRange.ts +0 -11
  81. package/src/getOverlapOfNonCircularRanges.ts +0 -41
  82. package/src/getOverlapsOfPotentiallyCircularRanges.ts +0 -60
  83. package/src/getPositionFromAngle.ts +0 -12
  84. package/src/getRangeAngles.ts +0 -38
  85. package/src/getRangeLength.test.ts +0 -30
  86. package/src/getRangeLength.ts +0 -17
  87. package/src/getRangesBetweenTwoRanges.ts +0 -42
  88. package/src/getSequenceWithinRange.test.ts +0 -47
  89. package/src/getSequenceWithinRange.ts +0 -24
  90. package/src/getShortestDistanceBetweenTwoPositions.test.ts +0 -12
  91. package/src/getShortestDistanceBetweenTwoPositions.ts +0 -16
  92. package/src/getYOffsetForPotentiallyCircularRange.ts +0 -37
  93. package/src/getYOffsetsForPotentiallyCircularRanges.test.ts +0 -17
  94. package/src/getYOffsetsForPotentiallyCircularRanges.ts +0 -28
  95. package/src/getZeroedRangeOverlaps.test.ts +0 -65
  96. package/src/getZeroedRangeOverlaps.ts +0 -33
  97. package/src/index.test.ts +0 -39
  98. package/src/index.ts +0 -53
  99. package/src/invertRange.ts +0 -25
  100. package/src/isPositionCloserToRangeStartThanRangeEnd.ts +0 -22
  101. package/src/isPositionWithinRange.ts +0 -40
  102. package/src/isRangeOrPositionWithinRange.ts +0 -40
  103. package/src/isRangeWithinRange.ts +0 -18
  104. package/src/loopEachPositionInRange.ts +0 -11
  105. package/src/modulatePositionByRange.ts +0 -15
  106. package/src/modulateRangeBySequenceLength.ts +0 -13
  107. package/src/normalizePositionByRangeLength.ts +0 -24
  108. package/src/normalizePositionByRangeLength1Based.ts +0 -9
  109. package/src/normalizeRange.ts +0 -12
  110. package/src/provideInclusiveOptions.ts +0 -79
  111. package/src/reversePositionInRange.ts +0 -17
  112. package/src/splitRangeIntoTwoPartsIfItIsCircular.ts +0 -36
  113. package/src/translateRange.ts +0 -21
  114. package/src/trimAnnStartEndToFitSeqLength.ts +0 -9
  115. package/src/trimNonCicularRangeByAnotherNonCircularRange.ts +0 -63
  116. package/src/trimNumberToFitWithin0ToAnotherNumber.ts +0 -15
  117. package/src/trimRangeByAnotherRange.ts +0 -103
  118. package/src/types.ts +0 -12
  119. package/src/zeroSubrangeByContainerRange.ts +0 -49
  120. package/types.d.ts +0 -12
package/index.js CHANGED
@@ -1564,10 +1564,9 @@ function getOverlapOfNonCircularRanges(rangeA, rangeB) {
1564
1564
  }
1565
1565
  }
1566
1566
  }
1567
- return null;
1568
1567
  }
1569
1568
  __name(getOverlapOfNonCircularRanges, "getOverlapOfNonCircularRanges");
1570
- function getOverlapsOfPotentiallyCircularRanges(rangeA, rangeB, maxRangeLength, joinIfPossible = false) {
1569
+ function getOverlapsOfPotentiallyCircularRanges(rangeA, rangeB, maxRangeLength, joinIfPossible) {
1571
1570
  const normalizedRangeA = splitRangeIntoTwoPartsIfItIsCircular(
1572
1571
  rangeA,
1573
1572
  maxRangeLength
@@ -1598,11 +1597,8 @@ function getOverlapsOfPotentiallyCircularRanges(rangeA, rangeB, maxRangeLength,
1598
1597
  joinedOverlap.start = o.start;
1599
1598
  return [];
1600
1599
  }
1601
- return [o];
1602
1600
  });
1603
- if (Object.keys(joinedOverlap).length > 0) {
1604
- overlaps.push(joinedOverlap);
1605
- }
1601
+ overlaps.push(joinedOverlap);
1606
1602
  }
1607
1603
  return overlaps;
1608
1604
  }
@@ -1675,7 +1671,10 @@ function trimRangeByAnotherRange(rangeToBeTrimmed, trimmingRange, sequenceLength
1675
1671
  if (!overlaps.length) {
1676
1672
  return rangeToBeTrimmed;
1677
1673
  }
1678
- const splitRangesToBeTrimmed = splitRangeIntoTwoPartsIfItIsCircular(rangeToBeTrimmed, sequenceLength);
1674
+ const splitRangesToBeTrimmed = splitRangeIntoTwoPartsIfItIsCircular(
1675
+ rangeToBeTrimmed,
1676
+ sequenceLength
1677
+ );
1679
1678
  splitRangesToBeTrimmed.forEach(function(nonCircularRangeToBeTrimmed, index) {
1680
1679
  overlaps.forEach(function(overlap) {
1681
1680
  if (nonCircularRangeToBeTrimmed) {
@@ -1718,7 +1717,6 @@ function trimRangeByAnotherRange(rangeToBeTrimmed, trimmingRange, sequenceLength
1718
1717
  end: outputTrimmedRange.end
1719
1718
  });
1720
1719
  }
1721
- return void 0;
1722
1720
  }
1723
1721
  __name(trimRangeByAnotherRange, "trimRangeByAnotherRange");
1724
1722
  function adjustRangeToDeletionOfAnotherRange(rangeToBeAdjusted, anotherRange, maxLength) {
@@ -1865,10 +1863,11 @@ function collapseOverlapsGeneratedFromRangeComparisonIfPossible(overlaps, sequen
1865
1863
  }
1866
1864
  }
1867
1865
  }
1868
- return overlaps;
1869
1866
  }
1870
1867
  __name(collapseOverlapsGeneratedFromRangeComparisonIfPossible, "collapseOverlapsGeneratedFromRangeComparisonIfPossible");
1871
- function convertRangeIndices(range, inputType = {}, outputType = {}) {
1868
+ function convertRangeIndices(range, inputType, outputType) {
1869
+ inputType = inputType || {};
1870
+ outputType = outputType || {};
1872
1871
  return assign({}, range, {
1873
1872
  start: Number(range.start) + (inputType.inclusive1BasedStart ? outputType.inclusive1BasedStart ? 0 : -1 : outputType.inclusive1BasedStart ? 1 : 0),
1874
1873
  end: Number(range.end) + (inputType.inclusive1BasedEnd ? outputType.inclusive1BasedEnd ? 0 : -1 : outputType.inclusive1BasedEnd ? 1 : 0)
@@ -1891,32 +1890,25 @@ function convertRangeTo1Based(range) {
1891
1890
  }
1892
1891
  __name(convertRangeTo1Based, "convertRangeTo1Based");
1893
1892
  function provideInclusiveOptions(funToWrap) {
1894
- return function(...args) {
1893
+ return function() {
1894
+ const args = Array.prototype.slice.call(arguments);
1895
1895
  const options = args[args.length - 1];
1896
1896
  if (options && (options.inclusive1BasedEnd || options.inclusive1BasedStart)) {
1897
1897
  args.forEach(function(arg, index) {
1898
- const potentialRange = arg;
1899
- if (potentialRange && typeof potentialRange.start === "number" && potentialRange.start > -1 && options.inclusive1BasedStart) {
1900
- args[index] = assign(potentialRange, {
1901
- start: potentialRange.start - 1
1902
- });
1898
+ if (arg && arg.start > -1 && options.inclusive1BasedStart) {
1899
+ args[index] = assign(arg, { start: arg.start - 1 });
1903
1900
  }
1904
- if (potentialRange && typeof potentialRange.end === "number" && potentialRange.end > -1 && options.inclusive1BasedEnd) {
1905
- args[index] = assign(potentialRange, {
1906
- end: potentialRange.end - 1
1907
- });
1901
+ if (arg && arg.end > -1 && options.inclusive1BasedEnd) {
1902
+ args[index] = assign(arg, { end: arg.end - 1 });
1908
1903
  }
1909
1904
  });
1910
1905
  }
1911
1906
  let returnVal = funToWrap.apply(this, args);
1912
- const potentialReturn = returnVal;
1913
- if (potentialReturn && typeof potentialReturn.start === "number" && potentialReturn.start > -1 && options && options.inclusive1BasedStart) {
1914
- returnVal = assign(potentialReturn, {
1915
- start: potentialReturn.start + 1
1916
- });
1907
+ if (returnVal && returnVal.start > -1 && options && options.inclusive1BasedStart) {
1908
+ returnVal = assign(returnVal, { start: returnVal.start + 1 });
1917
1909
  }
1918
- if (potentialReturn && typeof potentialReturn.end === "number" && potentialReturn.end > -1 && options && options.inclusive1BasedEnd) {
1919
- returnVal = assign(potentialReturn, { end: potentialReturn.end + 1 });
1910
+ if (returnVal && returnVal.end > -1 && options && options.inclusive1BasedEnd) {
1911
+ returnVal = assign(returnVal, { end: returnVal.end + 1 });
1920
1912
  }
1921
1913
  return returnVal;
1922
1914
  };
@@ -1937,10 +1929,9 @@ function getRangeLength$1(range, rangeMax) {
1937
1929
  }
1938
1930
  __name(getRangeLength$1, "getRangeLength$1");
1939
1931
  function doesRangeSpanEntireSequence(range, sequenceLength) {
1940
- if (getRangeLength(range, sequenceLength) === sequenceLength) {
1932
+ if (getRangeLength(range) === sequenceLength) {
1941
1933
  return true;
1942
1934
  }
1943
- return false;
1944
1935
  }
1945
1936
  __name(doesRangeSpanEntireSequence, "doesRangeSpanEntireSequence");
1946
1937
  function isRangeWithinRange(rangeToCheck, containingRange, maxLength) {
@@ -1974,9 +1965,6 @@ function isRangeOrPositionWithinRange(rangeOrPositionToCheck, containingRange, m
1974
1965
  return false;
1975
1966
  }
1976
1967
  if (isObject(rangeOrPositionToCheck)) {
1977
- if (typeof rangeOrPositionToCheck.start !== "number") {
1978
- return false;
1979
- }
1980
1968
  return isRangeWithinRange(
1981
1969
  rangeOrPositionToCheck,
1982
1970
  containingRange,
@@ -1997,7 +1985,7 @@ function doesRangeSpanOrigin(range) {
1997
1985
  return range.start > range.end;
1998
1986
  }
1999
1987
  __name(doesRangeSpanOrigin, "doesRangeSpanOrigin");
2000
- function normalizePositionByRangeLength(pPosition, sequenceLength, isInBetweenPositions = false) {
1988
+ function normalizePositionByRangeLength(pPosition, sequenceLength, isInBetweenPositions) {
2001
1989
  let position = pPosition;
2002
1990
  if (position < 0) {
2003
1991
  position += sequenceLength;
@@ -2089,7 +2077,10 @@ function expandOrContractRangeToPosition(range, position, maxLength) {
2089
2077
  if (range.start > range.end) {
2090
2078
  return expandOrContractCircularRangeToPosition(range, position, maxLength);
2091
2079
  } else {
2092
- return expandOrContractNonCircularRangeToPosition(range, position);
2080
+ return expandOrContractNonCircularRangeToPosition(
2081
+ range,
2082
+ position
2083
+ );
2093
2084
  }
2094
2085
  }
2095
2086
  __name(expandOrContractRangeToPosition, "expandOrContractRangeToPosition");
@@ -2353,9 +2344,7 @@ function getSequenceWithinRange(range, sequence) {
2353
2344
  if (typeof subSequence === "string") {
2354
2345
  subSequence += sequence.slice(0, range.end + 1);
2355
2346
  } else {
2356
- subSequence = subSequence.concat(
2357
- sequence.slice(0, range.end + 1)
2358
- );
2347
+ subSequence = subSequence.concat(sequence.slice(0, range.end + 1));
2359
2348
  }
2360
2349
  return subSequence;
2361
2350
  } else {
@@ -2375,7 +2364,7 @@ function getShortestDistanceBetweenTwoPositions(position1, position2, sequenceLe
2375
2364
  }
2376
2365
  __name(getShortestDistanceBetweenTwoPositions, "getShortestDistanceBetweenTwoPositions");
2377
2366
  function getYOffsetForPotentiallyCircularRange(range, YOffsetLevelsWithRanges, assignYOffsetToRange) {
2378
- let yOffset = 0;
2367
+ let yOffset = [];
2379
2368
  const openYOffsetFound = YOffsetLevelsWithRanges.some(
2380
2369
  function(rangesAlreadyAddedToYOffset, index) {
2381
2370
  const rangeBlocked = rangesAlreadyAddedToYOffset.some(
@@ -2425,20 +2414,21 @@ function getYOffsetsForPotentiallyCircularRanges(ranges, assignYOffsetToRange) {
2425
2414
  __name(getYOffsetsForPotentiallyCircularRanges, "getYOffsetsForPotentiallyCircularRanges");
2426
2415
  const invertRange = provideInclusiveOptions(invertRange$1);
2427
2416
  function invertRange$1(rangeOrCaret, rangeMax) {
2428
- if (typeof rangeOrCaret !== "number" && rangeOrCaret.start > -1) {
2417
+ if (rangeOrCaret.start > -1) {
2429
2418
  const start = rangeOrCaret.end + 1;
2430
2419
  const end = rangeOrCaret.start - 1;
2431
2420
  return {
2432
2421
  start: normalizePositionByRangeLength(start, rangeMax, false),
2433
2422
  end: normalizePositionByRangeLength(end, rangeMax, false)
2434
2423
  };
2435
- } else if (typeof rangeOrCaret === "number" && rangeOrCaret > -1) {
2436
- return {
2437
- start: normalizePositionByRangeLength(rangeOrCaret, rangeMax, false),
2438
- end: normalizePositionByRangeLength(rangeOrCaret - 1, rangeMax, false)
2439
- };
2424
+ } else {
2425
+ if (rangeOrCaret > -1) {
2426
+ return {
2427
+ start: normalizePositionByRangeLength(rangeOrCaret, rangeMax, false),
2428
+ end: normalizePositionByRangeLength(rangeOrCaret - 1, rangeMax, false)
2429
+ };
2430
+ }
2440
2431
  }
2441
- return void 0;
2442
2432
  }
2443
2433
  __name(invertRange$1, "invertRange$1");
2444
2434
  function isPositionCloserToRangeStartThanRangeEnd(position, range, maxLength) {
@@ -2506,10 +2496,9 @@ function zeroSubrangeByContainerRange(subRange, containerRange, sequenceLength)
2506
2496
  "subRange must be fully contained by containerRange! Otherwise this function does not make sense"
2507
2497
  );
2508
2498
  }
2509
- const newSubrange = {
2510
- start: subRange.start - containerRange.start,
2511
- end: subRange.end - containerRange.start
2512
- };
2499
+ const newSubrange = {};
2500
+ newSubrange.start = subRange.start - containerRange.start;
2501
+ newSubrange.end = subRange.end - containerRange.start;
2513
2502
  if (newSubrange.start < 0) {
2514
2503
  newSubrange.start += sequenceLength;
2515
2504
  }
@@ -2520,10 +2509,10 @@ function zeroSubrangeByContainerRange(subRange, containerRange, sequenceLength)
2520
2509
  }
2521
2510
  __name(zeroSubrangeByContainerRange, "zeroSubrangeByContainerRange");
2522
2511
  function adjustRangeToRotation(rangeToBeAdjusted, rotateTo = 0, rangeLength) {
2523
- const mod = /* @__PURE__ */ __name((n) => rangeLength ? modulo(n, rangeLength) : n, "mod");
2512
+ const mod = rangeLength ? modulo : identity;
2524
2513
  const newRange = assign({}, rangeToBeAdjusted, {
2525
- start: mod(rangeToBeAdjusted.start - (rotateTo || 0)),
2526
- end: mod(rangeToBeAdjusted.end - (rotateTo || 0))
2514
+ start: mod(rangeToBeAdjusted.start - (rotateTo || 0), rangeLength),
2515
+ end: mod(rangeToBeAdjusted.end - (rotateTo || 0), rangeLength)
2527
2516
  });
2528
2517
  return newRange;
2529
2518
  }
package/index.umd.cjs CHANGED
@@ -1568,10 +1568,9 @@ var __name = (target, value) => __defProp(target, "name", { value, configurable:
1568
1568
  }
1569
1569
  }
1570
1570
  }
1571
- return null;
1572
1571
  }
1573
1572
  __name(getOverlapOfNonCircularRanges, "getOverlapOfNonCircularRanges");
1574
- function getOverlapsOfPotentiallyCircularRanges(rangeA, rangeB, maxRangeLength, joinIfPossible = false) {
1573
+ function getOverlapsOfPotentiallyCircularRanges(rangeA, rangeB, maxRangeLength, joinIfPossible) {
1575
1574
  const normalizedRangeA = splitRangeIntoTwoPartsIfItIsCircular(
1576
1575
  rangeA,
1577
1576
  maxRangeLength
@@ -1602,11 +1601,8 @@ var __name = (target, value) => __defProp(target, "name", { value, configurable:
1602
1601
  joinedOverlap.start = o.start;
1603
1602
  return [];
1604
1603
  }
1605
- return [o];
1606
1604
  });
1607
- if (Object.keys(joinedOverlap).length > 0) {
1608
- overlaps.push(joinedOverlap);
1609
- }
1605
+ overlaps.push(joinedOverlap);
1610
1606
  }
1611
1607
  return overlaps;
1612
1608
  }
@@ -1679,7 +1675,10 @@ var __name = (target, value) => __defProp(target, "name", { value, configurable:
1679
1675
  if (!overlaps.length) {
1680
1676
  return rangeToBeTrimmed;
1681
1677
  }
1682
- const splitRangesToBeTrimmed = splitRangeIntoTwoPartsIfItIsCircular(rangeToBeTrimmed, sequenceLength);
1678
+ const splitRangesToBeTrimmed = splitRangeIntoTwoPartsIfItIsCircular(
1679
+ rangeToBeTrimmed,
1680
+ sequenceLength
1681
+ );
1683
1682
  splitRangesToBeTrimmed.forEach(function(nonCircularRangeToBeTrimmed, index) {
1684
1683
  overlaps.forEach(function(overlap) {
1685
1684
  if (nonCircularRangeToBeTrimmed) {
@@ -1722,7 +1721,6 @@ var __name = (target, value) => __defProp(target, "name", { value, configurable:
1722
1721
  end: outputTrimmedRange.end
1723
1722
  });
1724
1723
  }
1725
- return void 0;
1726
1724
  }
1727
1725
  __name(trimRangeByAnotherRange, "trimRangeByAnotherRange");
1728
1726
  function adjustRangeToDeletionOfAnotherRange(rangeToBeAdjusted, anotherRange, maxLength) {
@@ -1869,10 +1867,11 @@ var __name = (target, value) => __defProp(target, "name", { value, configurable:
1869
1867
  }
1870
1868
  }
1871
1869
  }
1872
- return overlaps;
1873
1870
  }
1874
1871
  __name(collapseOverlapsGeneratedFromRangeComparisonIfPossible, "collapseOverlapsGeneratedFromRangeComparisonIfPossible");
1875
- function convertRangeIndices(range, inputType = {}, outputType = {}) {
1872
+ function convertRangeIndices(range, inputType, outputType) {
1873
+ inputType = inputType || {};
1874
+ outputType = outputType || {};
1876
1875
  return assign({}, range, {
1877
1876
  start: Number(range.start) + (inputType.inclusive1BasedStart ? outputType.inclusive1BasedStart ? 0 : -1 : outputType.inclusive1BasedStart ? 1 : 0),
1878
1877
  end: Number(range.end) + (inputType.inclusive1BasedEnd ? outputType.inclusive1BasedEnd ? 0 : -1 : outputType.inclusive1BasedEnd ? 1 : 0)
@@ -1895,32 +1894,25 @@ var __name = (target, value) => __defProp(target, "name", { value, configurable:
1895
1894
  }
1896
1895
  __name(convertRangeTo1Based, "convertRangeTo1Based");
1897
1896
  function provideInclusiveOptions(funToWrap) {
1898
- return function(...args) {
1897
+ return function() {
1898
+ const args = Array.prototype.slice.call(arguments);
1899
1899
  const options = args[args.length - 1];
1900
1900
  if (options && (options.inclusive1BasedEnd || options.inclusive1BasedStart)) {
1901
1901
  args.forEach(function(arg, index) {
1902
- const potentialRange = arg;
1903
- if (potentialRange && typeof potentialRange.start === "number" && potentialRange.start > -1 && options.inclusive1BasedStart) {
1904
- args[index] = assign(potentialRange, {
1905
- start: potentialRange.start - 1
1906
- });
1902
+ if (arg && arg.start > -1 && options.inclusive1BasedStart) {
1903
+ args[index] = assign(arg, { start: arg.start - 1 });
1907
1904
  }
1908
- if (potentialRange && typeof potentialRange.end === "number" && potentialRange.end > -1 && options.inclusive1BasedEnd) {
1909
- args[index] = assign(potentialRange, {
1910
- end: potentialRange.end - 1
1911
- });
1905
+ if (arg && arg.end > -1 && options.inclusive1BasedEnd) {
1906
+ args[index] = assign(arg, { end: arg.end - 1 });
1912
1907
  }
1913
1908
  });
1914
1909
  }
1915
1910
  let returnVal = funToWrap.apply(this, args);
1916
- const potentialReturn = returnVal;
1917
- if (potentialReturn && typeof potentialReturn.start === "number" && potentialReturn.start > -1 && options && options.inclusive1BasedStart) {
1918
- returnVal = assign(potentialReturn, {
1919
- start: potentialReturn.start + 1
1920
- });
1911
+ if (returnVal && returnVal.start > -1 && options && options.inclusive1BasedStart) {
1912
+ returnVal = assign(returnVal, { start: returnVal.start + 1 });
1921
1913
  }
1922
- if (potentialReturn && typeof potentialReturn.end === "number" && potentialReturn.end > -1 && options && options.inclusive1BasedEnd) {
1923
- returnVal = assign(potentialReturn, { end: potentialReturn.end + 1 });
1914
+ if (returnVal && returnVal.end > -1 && options && options.inclusive1BasedEnd) {
1915
+ returnVal = assign(returnVal, { end: returnVal.end + 1 });
1924
1916
  }
1925
1917
  return returnVal;
1926
1918
  };
@@ -1941,10 +1933,9 @@ var __name = (target, value) => __defProp(target, "name", { value, configurable:
1941
1933
  }
1942
1934
  __name(getRangeLength$1, "getRangeLength$1");
1943
1935
  function doesRangeSpanEntireSequence(range, sequenceLength) {
1944
- if (getRangeLength(range, sequenceLength) === sequenceLength) {
1936
+ if (getRangeLength(range) === sequenceLength) {
1945
1937
  return true;
1946
1938
  }
1947
- return false;
1948
1939
  }
1949
1940
  __name(doesRangeSpanEntireSequence, "doesRangeSpanEntireSequence");
1950
1941
  function isRangeWithinRange(rangeToCheck, containingRange, maxLength) {
@@ -1978,9 +1969,6 @@ var __name = (target, value) => __defProp(target, "name", { value, configurable:
1978
1969
  return false;
1979
1970
  }
1980
1971
  if (isObject(rangeOrPositionToCheck)) {
1981
- if (typeof rangeOrPositionToCheck.start !== "number") {
1982
- return false;
1983
- }
1984
1972
  return isRangeWithinRange(
1985
1973
  rangeOrPositionToCheck,
1986
1974
  containingRange,
@@ -2001,7 +1989,7 @@ var __name = (target, value) => __defProp(target, "name", { value, configurable:
2001
1989
  return range.start > range.end;
2002
1990
  }
2003
1991
  __name(doesRangeSpanOrigin, "doesRangeSpanOrigin");
2004
- function normalizePositionByRangeLength(pPosition, sequenceLength, isInBetweenPositions = false) {
1992
+ function normalizePositionByRangeLength(pPosition, sequenceLength, isInBetweenPositions) {
2005
1993
  let position = pPosition;
2006
1994
  if (position < 0) {
2007
1995
  position += sequenceLength;
@@ -2093,7 +2081,10 @@ var __name = (target, value) => __defProp(target, "name", { value, configurable:
2093
2081
  if (range.start > range.end) {
2094
2082
  return expandOrContractCircularRangeToPosition(range, position, maxLength);
2095
2083
  } else {
2096
- return expandOrContractNonCircularRangeToPosition(range, position);
2084
+ return expandOrContractNonCircularRangeToPosition(
2085
+ range,
2086
+ position
2087
+ );
2097
2088
  }
2098
2089
  }
2099
2090
  __name(expandOrContractRangeToPosition, "expandOrContractRangeToPosition");
@@ -2357,9 +2348,7 @@ var __name = (target, value) => __defProp(target, "name", { value, configurable:
2357
2348
  if (typeof subSequence === "string") {
2358
2349
  subSequence += sequence.slice(0, range.end + 1);
2359
2350
  } else {
2360
- subSequence = subSequence.concat(
2361
- sequence.slice(0, range.end + 1)
2362
- );
2351
+ subSequence = subSequence.concat(sequence.slice(0, range.end + 1));
2363
2352
  }
2364
2353
  return subSequence;
2365
2354
  } else {
@@ -2379,7 +2368,7 @@ var __name = (target, value) => __defProp(target, "name", { value, configurable:
2379
2368
  }
2380
2369
  __name(getShortestDistanceBetweenTwoPositions, "getShortestDistanceBetweenTwoPositions");
2381
2370
  function getYOffsetForPotentiallyCircularRange(range, YOffsetLevelsWithRanges, assignYOffsetToRange) {
2382
- let yOffset = 0;
2371
+ let yOffset = [];
2383
2372
  const openYOffsetFound = YOffsetLevelsWithRanges.some(
2384
2373
  function(rangesAlreadyAddedToYOffset, index) {
2385
2374
  const rangeBlocked = rangesAlreadyAddedToYOffset.some(
@@ -2429,20 +2418,21 @@ var __name = (target, value) => __defProp(target, "name", { value, configurable:
2429
2418
  __name(getYOffsetsForPotentiallyCircularRanges, "getYOffsetsForPotentiallyCircularRanges");
2430
2419
  const invertRange = provideInclusiveOptions(invertRange$1);
2431
2420
  function invertRange$1(rangeOrCaret, rangeMax) {
2432
- if (typeof rangeOrCaret !== "number" && rangeOrCaret.start > -1) {
2421
+ if (rangeOrCaret.start > -1) {
2433
2422
  const start = rangeOrCaret.end + 1;
2434
2423
  const end = rangeOrCaret.start - 1;
2435
2424
  return {
2436
2425
  start: normalizePositionByRangeLength(start, rangeMax, false),
2437
2426
  end: normalizePositionByRangeLength(end, rangeMax, false)
2438
2427
  };
2439
- } else if (typeof rangeOrCaret === "number" && rangeOrCaret > -1) {
2440
- return {
2441
- start: normalizePositionByRangeLength(rangeOrCaret, rangeMax, false),
2442
- end: normalizePositionByRangeLength(rangeOrCaret - 1, rangeMax, false)
2443
- };
2428
+ } else {
2429
+ if (rangeOrCaret > -1) {
2430
+ return {
2431
+ start: normalizePositionByRangeLength(rangeOrCaret, rangeMax, false),
2432
+ end: normalizePositionByRangeLength(rangeOrCaret - 1, rangeMax, false)
2433
+ };
2434
+ }
2444
2435
  }
2445
- return void 0;
2446
2436
  }
2447
2437
  __name(invertRange$1, "invertRange$1");
2448
2438
  function isPositionCloserToRangeStartThanRangeEnd(position, range, maxLength) {
@@ -2510,10 +2500,9 @@ var __name = (target, value) => __defProp(target, "name", { value, configurable:
2510
2500
  "subRange must be fully contained by containerRange! Otherwise this function does not make sense"
2511
2501
  );
2512
2502
  }
2513
- const newSubrange = {
2514
- start: subRange.start - containerRange.start,
2515
- end: subRange.end - containerRange.start
2516
- };
2503
+ const newSubrange = {};
2504
+ newSubrange.start = subRange.start - containerRange.start;
2505
+ newSubrange.end = subRange.end - containerRange.start;
2517
2506
  if (newSubrange.start < 0) {
2518
2507
  newSubrange.start += sequenceLength;
2519
2508
  }
@@ -2524,10 +2513,10 @@ var __name = (target, value) => __defProp(target, "name", { value, configurable:
2524
2513
  }
2525
2514
  __name(zeroSubrangeByContainerRange, "zeroSubrangeByContainerRange");
2526
2515
  function adjustRangeToRotation(rangeToBeAdjusted, rotateTo = 0, rangeLength) {
2527
- const mod = /* @__PURE__ */ __name((n) => rangeLength ? modulo(n, rangeLength) : n, "mod");
2516
+ const mod = rangeLength ? modulo : identity;
2528
2517
  const newRange = assign({}, rangeToBeAdjusted, {
2529
- start: mod(rangeToBeAdjusted.start - (rotateTo || 0)),
2530
- end: mod(rangeToBeAdjusted.end - (rotateTo || 0))
2518
+ start: mod(rangeToBeAdjusted.start - (rotateTo || 0), rangeLength),
2519
+ end: mod(rangeToBeAdjusted.end - (rotateTo || 0), rangeLength)
2531
2520
  });
2532
2521
  return newRange;
2533
2522
  }
package/invertRange.d.ts CHANGED
@@ -1,6 +1,2 @@
1
- import { Range } from './types';
2
- declare const _default: (rangeOrCaret: number | Range, rangeMax: number, options?: {
3
- inclusive1BasedEnd?: boolean;
4
- inclusive1BasedStart?: boolean;
5
- } | undefined) => Range | undefined;
1
+ declare const _default: (...args: any[]) => any;
6
2
  export default _default;
@@ -1,2 +1 @@
1
- import { Range } from './types';
2
- export default function isPositionCloserToRangeStartThanRangeEnd(position: number, range: Range, maxLength: number): boolean;
1
+ export default function isPositionCloserToRangeStartThanRangeEnd(position: any, range: any, maxLength: any): boolean;
@@ -1,4 +1,4 @@
1
- import { Range } from './types';
1
+ export default isPositionWithinRange;
2
2
  /**
3
3
  *
4
4
  * @param {*} position //assumed to be a 0 based "caretPosition"
@@ -6,5 +6,4 @@ import { Range } from './types';
6
6
  * @param {*} sequenceLength
7
7
  * @param {*} includeEdges - (default false) whether or not to say
8
8
  */
9
- declare function isPositionWithinRange(position: number, range: Range, sequenceLength: number, includeStartEdge?: boolean, includeEndEdge?: boolean): boolean;
10
- export default isPositionWithinRange;
9
+ declare function isPositionWithinRange(position: any, range: any, sequenceLength: any, includeStartEdge: any, includeEndEdge: any): boolean;
@@ -1,2 +1 @@
1
- import { Range } from './types';
2
- export default function isRangeOrPositionWithinRange(rangeOrPositionToCheck: Range | number, containingRange: Range, maxLength: number, includeStartEdge?: boolean, includeEndEdge?: boolean): boolean;
1
+ export default function isRangeOrPositionWithinRange(rangeOrPositionToCheck: any, containingRange: any, maxLength: any, includeStartEdge: any, includeEndEdge: any): boolean;
@@ -1,2 +1 @@
1
- import { Range } from './types';
2
- export default function isRangeWithinRange(rangeToCheck: Range, containingRange: Range, maxLength: number): boolean;
1
+ export default function isRangeWithinRange(rangeToCheck: any, containingRange: any, maxLength: any): boolean;
@@ -1,2 +1 @@
1
- import { Range } from './types';
2
- export default function loopEachPositionInRange(range: Range, rangeMax: number, func: (pos: number) => void): void;
1
+ export default function loopEachPositionInRange(range: any, rangeMax: any, func: any): void;
@@ -1,2 +1 @@
1
- import { Range } from './types';
2
- export default function modulatePositionByRange(position: number, range: Range): number;
1
+ export default function modulatePositionByRange(position: any, range: any): any;
@@ -1,9 +1,2 @@
1
- import { Range } from './types';
2
- declare const _default: (range: Range, seqLen: number, options?: {
3
- inclusive1BasedEnd?: boolean;
4
- inclusive1BasedStart?: boolean;
5
- } | undefined) => Range & {
6
- start: number;
7
- end: number;
8
- };
1
+ declare const _default: (...args: any[]) => any;
9
2
  export default _default;
@@ -1 +1 @@
1
- export default function normalizePositionByRangeLength(pPosition: number, sequenceLength: number, isInBetweenPositions?: boolean): number;
1
+ export default function normalizePositionByRangeLength(pPosition: any, sequenceLength: any, isInBetweenPositions: any): any;
@@ -1 +1 @@
1
- export default function normalizePositionByRangeLength1Based(position: number, sequenceLength: number): number;
1
+ export default function normalizePositionByRangeLength1Based(position: any, sequenceLength: any): any;
@@ -1,5 +1 @@
1
- import { Range } from './types';
2
- export default function normalizeRange(range: Range, sequenceLength: number): Range & {
3
- start: number;
4
- end: number;
5
- };
1
+ export default function normalizeRange(range: any, sequenceLength: any): any;
package/package.json CHANGED
@@ -1,17 +1,9 @@
1
1
  {
2
2
  "name": "@teselagen/range-utils",
3
- "version": "0.3.14-beta.3",
3
+ "version": "0.3.18",
4
4
  "type": "module",
5
+ "repository": "https://github.com/TeselaGen/tg-oss",
5
6
  "dependencies": {
6
7
  "lodash-es": "^4.17.21"
7
- },
8
- "main": "./src/index.ts",
9
- "exports": {
10
- ".": {
11
- "import": "./src/index.ts",
12
- "require": "./src/index.ts"
13
- }
14
- },
15
- "types": "./src/index.ts",
16
- "license": "MIT"
17
- }
8
+ }
9
+ }
@@ -1,6 +1 @@
1
- type Options = {
2
- inclusive1BasedEnd?: boolean;
3
- inclusive1BasedStart?: boolean;
4
- };
5
- export default function provideInclusiveOptions<T extends (...args: any[]) => any>(funToWrap: T): (...args: [...Parameters<T>, options?: Options]) => ReturnType<T>;
6
- export {};
1
+ export default function provideInclusiveOptions(funToWrap: any): (...args: any[]) => any;
@@ -1 +1 @@
1
- export default function reversePositionInRange(position: number, rangeLength: number, isInBetweenPositions: boolean): number;
1
+ export default function reversePositionInRange(position: any, rangeLength: any, isInBetweenPositions: any): number;
@@ -1,6 +1,5 @@
1
- import { Range } from './types';
2
- export default function splitRangeIntoTwoPartsIfItIsCircular(range: Range, sequenceLength: number): {
3
- start: number;
4
- end: number;
1
+ export default function splitRangeIntoTwoPartsIfItIsCircular(range: any, sequenceLength: any): {
2
+ start: any;
3
+ end: any;
5
4
  type: string;
6
5
  }[];
@@ -1,5 +1 @@
1
- import { Range } from './types';
2
- export default function translateRange(rangeToBeAdjusted: Range, translateBy: number, rangeLength: number): Range & {
3
- start: number;
4
- end: number;
5
- };
1
+ export default function translateRange(rangeToBeAdjusted: any, translateBy: any, rangeLength: any): any;
@@ -1 +1 @@
1
- export default function trimAnnStartEndToFitSeqLength(annStartOrEnd: number, sequenceLength: number): number;
1
+ export default function trimAnnStartEndToFitSeqLength(annStartOrEnd: any, sequenceLength: any): number;
@@ -1,2 +1,4 @@
1
- import { Range } from './types';
2
- export default function trimNonCicularRangeByAnotherNonCircularRange(rangeToBeTrimmed: Range, trimmingRange: Range): Range | undefined;
1
+ export default function trimNonCicularRangeByAnotherNonCircularRange(rangeToBeTrimmed: any, trimmingRange: any): {
2
+ start: any;
3
+ end: any;
4
+ } | undefined;
@@ -1 +1 @@
1
- export default function trimNumberToFitWithin0ToAnotherNumber(numberToBeTrimmed: number, max: number): number;
1
+ export default function trimNumberToFitWithin0ToAnotherNumber(numberToBeTrimmed: any, max: any): any;
@@ -1,4 +1,3 @@
1
- import { Range } from './types';
2
1
  /**
3
2
  * trims range, but does *not* adjust it
4
3
  * returns a new range if there is one, or null, if it is trimmed completely
@@ -13,4 +12,4 @@ import { Range } from './types';
13
12
  * end:
14
13
  * }
15
14
  */
16
- export default function trimRangeByAnotherRange(rangeToBeTrimmed: Range, trimmingRange: Range, sequenceLength: number): Range | undefined | null;
15
+ export default function trimRangeByAnotherRange(rangeToBeTrimmed: any, trimmingRange: any, sequenceLength: int): object;
@@ -1,4 +1,3 @@
1
- import { Range } from './types';
2
1
  /**
3
2
  * "zeroes" a subrange of a container range by
4
3
  * adjusting subRange start and end such that it is as if the container range start = 0.
@@ -13,4 +12,4 @@ import { Range } from './types';
13
12
  * end:
14
13
  * }
15
14
  */
16
- export default function zeroSubrangeByContainerRange(subRange: Range, containerRange: Range, sequenceLength: number): Range;
15
+ export default function zeroSubrangeByContainerRange(subRange: object, containerRange: object, sequenceLength: int): object;
package/RangeAngles.d.ts DELETED
@@ -1,7 +0,0 @@
1
- export interface RangeAngles {
2
- startAngle: number;
3
- totalAngle: number;
4
- endAngle: number;
5
- centerAngle: number;
6
- locationAngles?: RangeAngles[];
7
- }
@@ -1,9 +0,0 @@
1
- //
2
-
3
- export interface RangeAngles {
4
- startAngle: number;
5
- totalAngle: number;
6
- endAngle: number;
7
- centerAngle: number;
8
- locationAngles?: RangeAngles[];
9
- }