summaryrefslogtreecommitdiff
path: root/node_modules/source-map/lib/binary-search.js
diff options
context:
space:
mode:
authorlittleblack111 <littleblack11111@gmail.com>2023-11-05 17:23:37 +0800
committerlittleblack111 <littleblack11111@gmail.com>2023-11-05 17:23:37 +0800
commit2cdf0cb352ab6a2d0f8cb25120e4ebc92c5316e3 (patch)
tree6b088c99810bd013f17b80522c936ca6dfc09858 /node_modules/source-map/lib/binary-search.js
parentf8ee6ef722e6c560c4a1c879e04dbdf0b01f0316 (diff)
removed autoprefix hover as it will have a high chance of making hover stopped working
Diffstat (limited to 'node_modules/source-map/lib/binary-search.js')
-rw-r--r--node_modules/source-map/lib/binary-search.js34
1 files changed, 19 insertions, 15 deletions
diff --git a/node_modules/source-map/lib/binary-search.js b/node_modules/source-map/lib/binary-search.js
index d6f898ea..010ac941 100644
--- a/node_modules/source-map/lib/binary-search.js
+++ b/node_modules/source-map/lib/binary-search.js
@@ -31,12 +31,13 @@ function recursiveSearch(aLow, aHigh, aNeedle, aHaystack, aCompare, aBias) {
//
// 3. We did not find the exact element, and there is no next-closest
// element than the one we are searching for, so we return -1.
- const mid = Math.floor((aHigh - aLow) / 2) + aLow;
- const cmp = aCompare(aNeedle, aHaystack[mid], true);
+ var mid = Math.floor((aHigh - aLow) / 2) + aLow;
+ var cmp = aCompare(aNeedle, aHaystack[mid], true);
if (cmp === 0) {
// Found the element we are looking for.
return mid;
- } else if (cmp > 0) {
+ }
+ else if (cmp > 0) {
// Our needle is greater than aHaystack[mid].
if (aHigh - mid > 1) {
// The element is in the upper half.
@@ -47,21 +48,24 @@ function recursiveSearch(aLow, aHigh, aNeedle, aHaystack, aCompare, aBias) {
// we are in termination case (3) or (2) and return the appropriate thing.
if (aBias == exports.LEAST_UPPER_BOUND) {
return aHigh < aHaystack.length ? aHigh : -1;
+ } else {
+ return mid;
}
- return mid;
- }
-
- // Our needle is less than aHaystack[mid].
- if (mid - aLow > 1) {
- // The element is in the lower half.
- return recursiveSearch(aLow, mid, aNeedle, aHaystack, aCompare, aBias);
}
+ else {
+ // Our needle is less than aHaystack[mid].
+ if (mid - aLow > 1) {
+ // The element is in the lower half.
+ return recursiveSearch(aLow, mid, aNeedle, aHaystack, aCompare, aBias);
+ }
- // we are in termination case (3) or (2) and return the appropriate thing.
- if (aBias == exports.LEAST_UPPER_BOUND) {
- return mid;
+ // we are in termination case (3) or (2) and return the appropriate thing.
+ if (aBias == exports.LEAST_UPPER_BOUND) {
+ return mid;
+ } else {
+ return aLow < 0 ? -1 : aLow;
+ }
}
- return aLow < 0 ? -1 : aLow;
}
/**
@@ -87,7 +91,7 @@ exports.search = function search(aNeedle, aHaystack, aCompare, aBias) {
return -1;
}
- let index = recursiveSearch(-1, aHaystack.length, aNeedle, aHaystack,
+ var index = recursiveSearch(-1, aHaystack.length, aNeedle, aHaystack,
aCompare, aBias || exports.GREATEST_LOWER_BOUND);
if (index < 0) {
return -1;