Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
//new range passed
// return selectionLayerUpdate(newRange);
let selectionFullyContained = !trimRangeByAnotherRange(
selectionLayer,
newRange
);
if (selectionFullyContained) {
return selectionLayerUpdate(newRange);
}
let newRangeFullyContained = !trimRangeByAnotherRange(
newRange,
selectionLayer
);
let { newRange: range1 } = expandOrContractRangeToPosition(
selectionLayer,
newRange.start,
sequenceLength
);
let { newRange: range2 } = expandOrContractRangeToPosition(
selectionLayer,
newRange.end + 1,
sequenceLength
); //+1 to go from range end to position
let range1Shorter =
getRangeLength(range1, sequenceLength) <
getRangeLength(range2, sequenceLength);
if (newRangeFullyContained) {
range1Shorter
? selectionLayerUpdate(range1)
);
if (selectionFullyContained) {
return selectionLayerUpdate(newRange);
}
let newRangeFullyContained = !trimRangeByAnotherRange(
newRange,
selectionLayer
);
let { newRange: range1 } = expandOrContractRangeToPosition(
selectionLayer,
newRange.start,
sequenceLength
);
let { newRange: range2 } = expandOrContractRangeToPosition(
selectionLayer,
newRange.end + 1,
sequenceLength
); //+1 to go from range end to position
let range1Shorter =
getRangeLength(range1, sequenceLength) <
getRangeLength(range2, sequenceLength);
if (newRangeFullyContained) {
range1Shorter
? selectionLayerUpdate(range1)
: selectionLayerUpdate(range2);
} else {
selectionLayerUpdate({
start: selectionLayer.start,
end: newRange.end
);
if (selectionFullyContained) {
return selectionLayerUpdate(newRange);
}
let newRangeFullyContained = !trimRangeByAnotherRange(
newRange,
selectionLayer
);
let { newRange: range1 } = expandOrContractRangeToPosition(
selectionLayer,
newRange.start,
sequenceLength
);
let { newRange: range2 } = expandOrContractRangeToPosition(
selectionLayer,
newRange.end + 1,
sequenceLength
); //+1 to go from range end to position
let range1Shorter = getRangeLength(range1) < getRangeLength(range2);
if (newRangeFullyContained) {
range1Shorter
? selectionLayerUpdate(range1)
: selectionLayerUpdate(range2);
} else {
range1Shorter
? selectionLayerUpdate(range2)
: selectionLayerUpdate(range1);
}
}
} else {
//new range passed
let selectionFullyContained = !trimRangeByAnotherRange(
selectionLayer,
newRange
);
if (selectionFullyContained) {
return selectionLayerUpdate(newRange);
}
let newRangeFullyContained = !trimRangeByAnotherRange(
newRange,
selectionLayer
);
let { newRange: range1 } = expandOrContractRangeToPosition(
selectionLayer,
newRange.start,
sequenceLength
);
let { newRange: range2 } = expandOrContractRangeToPosition(
selectionLayer,
newRange.end + 1,
sequenceLength
); //+1 to go from range end to position
let range1Shorter = getRangeLength(range1) < getRangeLength(range2);
if (newRangeFullyContained) {
range1Shorter
? selectionLayerUpdate(range1)
: selectionLayerUpdate(range2);
} else {