summaryrefslogtreecommitdiff
path: root/node_modules/source-map/lib/binary-search.js
diff options
context:
space:
mode:
authorlittleblack111 <littleblack11111@gmail.com>2024-10-13 10:37:19 +0800
committerlittleblack111 <littleblack11111@gmail.com>2024-10-13 10:37:19 +0800
commite29b244aeab08ea36fb385c7beb2ad0560217039 (patch)
treec66b744dc29573f1acc871862937a23f1b80e6bf /node_modules/source-map/lib/binary-search.js
parent62c2881629e6413a8fec6d3dd092e4568e2a81dc (diff)
bump: @babel/cli 7.25.6 → 7.25.7, @babel/core 7.25.2 → 7.25.8, @babel/preset-env 7.25.4 → 7.25.8, postcss 8.4.41 → 8.4.47, swup 4.7.0 → 4.8.1
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;